This commit is contained in:
Raymond Hettinger 2015-05-11 19:59:21 -07:00
commit 4e6bf4b3da
1 changed files with 5 additions and 0 deletions

View File

@ -235,6 +235,11 @@ heappushpop(PyObject *self, PyObject *args)
return item;
}
if (PyList_GET_SIZE(heap) == 0) {
PyErr_SetString(PyExc_IndexError, "index out of range");
return NULL;
}
returnitem = PyList_GET_ITEM(heap, 0);
Py_INCREF(item);
PyList_SET_ITEM(heap, 0, item);