From 764a46d2ed3a70b67be58ac93470837e33a7ed19 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 17 Jul 2013 21:50:21 +0200 Subject: Issue #18408: Fix heapq.heappop(), handle PyList_SetSlice() failure --- Modules/_heapqmodule.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Modules/_heapqmodule.c') 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) -- cgit v1.2.1