summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 2bab4ef..09fba48 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 = PyUnicode_FromString(
"list index out of range");
+ if (indexerr == NULL)
+ return NULL;
+ }
PyErr_SetObject(PyExc_IndexError, indexerr);
return NULL;
}
@@ -406,9 +409,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 = PyUnicode_FromString(
"list index out of range");
+ if (indexerr == NULL)
+ return NULL;
+ }
PyErr_SetObject(PyExc_IndexError, indexerr);
return NULL;
}