commit | b9db9e152f3325b075e59ef4fdecfd0b9ec4746c | [log] [tgz] |
---|---|---|
author | Raymond Hettinger <python@rcn.com> | Mon May 11 19:58:56 2015 -0700 |
committer | Raymond Hettinger <python@rcn.com> | Mon May 11 19:58:56 2015 -0700 |
tree | 94395cbc2ae10300d1aba7c735abec04e7756850 | |
parent | 1af2bf75a2f816eaaf8353eaab8b6dcfee0064c0 [diff] |
Defend against a mutation during comparison
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 @@ 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);