]> granicus.if.org Git - python/commitdiff
Issue #18408: Fix heapq.heappop(), handle PyList_SetSlice() failure
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 17 Jul 2013 19:50:21 +0000 (21:50 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 17 Jul 2013 19:50:21 +0000 (21:50 +0200)
Modules/_heapqmodule.c

index f377e9cf6cf2ce0f1438f7dcdb414d92e35b76b4..96afcdc1b37791f4e70fc9c7a8d28e75c2c64622 100644 (file)
@@ -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)