diff options
author | Raymond Hettinger <python@rcn.com> | 2015-05-12 02:58:56 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2015-05-12 02:58:56 (GMT) |
commit | b9db9e152f3325b075e59ef4fdecfd0b9ec4746c (patch) | |
tree | 94395cbc2ae10300d1aba7c735abec04e7756850 | |
parent | 1af2bf75a2f816eaaf8353eaab8b6dcfee0064c0 (diff) | |
download | cpython-b9db9e152f3325b075e59ef4fdecfd0b9ec4746c.zip cpython-b9db9e152f3325b075e59ef4fdecfd0b9ec4746c.tar.gz cpython-b9db9e152f3325b075e59ef4fdecfd0b9ec4746c.tar.bz2 |
Defend against a mutation during comparison
-rw-r--r-- | Modules/_heapqmodule.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c index 38bcdbe..04845f1 100644 --- a/Modules/_heapqmodule.c +++ b/Modules/_heapqmodule.c @@ -224,6 +224,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); |