diff options
Diffstat (limited to 'Modules/_heapqmodule.c')
-rw-r--r-- | Modules/_heapqmodule.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c index f377e9c..96afcdc 100644 --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -168,7 +168,10 @@ heappop(PyObject *self, PyObject *heap) lastelt = PyList_GET_ITEM(heap, n-1) ; Py_INCREF(lastelt); - PyList_SetSlice(heap, n-1, n, NULL); + if (PyList_SetSlice(heap, n-1, n, NULL) < 0) { + Py_DECREF(lastelt); + return NULL; + } n--; if (!n) |