From: Victor Stinner Date: Wed, 17 Jul 2013 19:50:21 +0000 (+0200) Subject: Issue #18408: Fix heapq.heappop(), handle PyList_SetSlice() failure X-Git-Tag: v3.4.0a1~168 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=764a46d2ed3a70b67be58ac93470837e33a7ed19;p=python Issue #18408: Fix heapq.heappop(), handle PyList_SetSlice() failure --- diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c index f377e9cf6c..96afcdc1b3 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)