summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-11-02 15:06:45 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-11-02 15:06:45 (GMT)
commite2caf1f60ec182558de96526cae12962926ae92a (patch)
treee9acbe036b84a2654ec7afa173c0c2746166b01e
parentaec4124fed3b22279f272a527f4c2640beadad3d (diff)
downloadcpython-e2caf1f60ec182558de96526cae12962926ae92a.zip
cpython-e2caf1f60ec182558de96526cae12962926ae92a.tar.gz
cpython-e2caf1f60ec182558de96526cae12962926ae92a.tar.bz2
prevent a rather unlikely segfault
-rw-r--r--Objects/listobject.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index c5b1475..39b8b1a 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -183,9 +183,12 @@ PyList_GetItem(PyObject *op, Py_ssize_t i)
return NULL;
}
if (i < 0 || i >= Py_SIZE(op)) {
- if (indexerr == NULL)
+ if (indexerr == NULL) {
indexerr = PyString_FromString(
"list index out of range");
+ if (indexerr == NULL)
+ return NULL;
+ }
PyErr_SetObject(PyExc_IndexError, indexerr);
return NULL;
}
@@ -447,9 +450,12 @@ static PyObject *
list_item(PyListObject *a, Py_ssize_t i)
{
if (i < 0 || i >= Py_SIZE(a)) {
- if (indexerr == NULL)
+ if (indexerr == NULL) {
indexerr = PyString_FromString(
"list index out of range");
+ if (indexerr == NULL)
+ return NULL;
+ }
PyErr_SetObject(PyExc_IndexError, indexerr);
return NULL;
}