Kaydet (Commit) e2caf1f6 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

prevent a rather unlikely segfault

üst aec4124f
...@@ -183,9 +183,12 @@ PyList_GetItem(PyObject *op, Py_ssize_t i) ...@@ -183,9 +183,12 @@ PyList_GetItem(PyObject *op, Py_ssize_t i)
return NULL; return NULL;
} }
if (i < 0 || i >= Py_SIZE(op)) { if (i < 0 || i >= Py_SIZE(op)) {
if (indexerr == NULL) if (indexerr == NULL) {
indexerr = PyString_FromString( indexerr = PyString_FromString(
"list index out of range"); "list index out of range");
if (indexerr == NULL)
return NULL;
}
PyErr_SetObject(PyExc_IndexError, indexerr); PyErr_SetObject(PyExc_IndexError, indexerr);
return NULL; return NULL;
} }
...@@ -447,9 +450,12 @@ static PyObject * ...@@ -447,9 +450,12 @@ static PyObject *
list_item(PyListObject *a, Py_ssize_t i) list_item(PyListObject *a, Py_ssize_t i)
{ {
if (i < 0 || i >= Py_SIZE(a)) { if (i < 0 || i >= Py_SIZE(a)) {
if (indexerr == NULL) if (indexerr == NULL) {
indexerr = PyString_FromString( indexerr = PyString_FromString(
"list index out of range"); "list index out of range");
if (indexerr == NULL)
return NULL;
}
PyErr_SetObject(PyExc_IndexError, indexerr); PyErr_SetObject(PyExc_IndexError, indexerr);
return NULL; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment