[Python-checkins] cpython (2.7): Defend against a mutation during comparison
raymond.hettinger
python-checkins at python.org
Tue May 12 05:00:49 CEST 2015
https://hg.python.org/cpython/rev/0e8a17f437b5
changeset: 95968:0e8a17f437b5
branch: 2.7
parent: 95950:0f7795edca65
user: Raymond Hettinger <python at rcn.com>
date: Mon May 11 20:00:25 2015 -0700
summary:
Defend against a mutation during comparison
files:
Modules/_heapqmodule.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c
--- a/Modules/_heapqmodule.c
+++ b/Modules/_heapqmodule.c
@@ -244,6 +244,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);
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list