diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-17 19:50:21 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-17 19:50:21 (GMT) |
commit | 764a46d2ed3a70b67be58ac93470837e33a7ed19 (patch) | |
tree | 585a9f98151e2bcff65ccad86c1daf05d963cc13 /Modules/_heapqmodule.c | |
parent | 2ff51b83b88b65818479706f2d5238c52bbae296 (diff) | |
download | cpython-764a46d2ed3a70b67be58ac93470837e33a7ed19.zip cpython-764a46d2ed3a70b67be58ac93470837e33a7ed19.tar.gz cpython-764a46d2ed3a70b67be58ac93470837e33a7ed19.tar.bz2 |
Issue #18408: Fix heapq.heappop(), handle PyList_SetSlice() failure
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) |