Skip to content

Commit b9db9e1

Browse files
committed
Defend against a mutation during comparison
1 parent 1af2bf7 commit b9db9e1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Modules/_heapqmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ heappushpop(PyObject *self, PyObject *args)
224224
return item;
225225
}
226226

227+
if (PyList_GET_SIZE(heap) == 0) {
228+
PyErr_SetString(PyExc_IndexError, "index out of range");
229+
return NULL;
230+
}
231+
227232
returnitem = PyList_GET_ITEM(heap, 0);
228233
Py_INCREF(item);
229234
PyList_SET_ITEM(heap, 0, item);

0 commit comments

Comments
 (0)