]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Defend against a mutation during comparison
authorRaymond Hettinger <python@rcn.com>
Tue, 12 May 2015 03:00:25 +0000 (20:00 -0700)
committerRaymond Hettinger <python@rcn.com>
Tue, 12 May 2015 03:00:25 +0000 (20:00 -0700)
Modules/_heapqmodule.c

index d0ddb09fb1593372a9d3ce5ca4a06a9f69e40141..be301a62fc6222a833a8ecd078be1a7040084f23 100644 (file)
@@ -244,6 +244,11 @@ heappushpop(PyObject *self, PyObject *args)
         return item;
     }
 
+    if (PyList_GET_SIZE(heap) == 0) {
+        PyErr_SetString(PyExc_IndexError, "index out of range");
+        return NULL;
+    }
+
     returnitem = PyList_GET_ITEM(heap, 0);
     Py_INCREF(item);
     PyList_SET_ITEM(heap, 0, item);