Check for overflow in list object insertion and raise OverflowError.

see: http://www.python.org/pipermail/python-dev/2000-August/014971.html
This commit is contained in:
Trent Mick 2000-08-13 22:47:45 +00:00
parent 87df80d542
commit a584664134
1 changed files with 5 additions and 0 deletions

View File

@ -134,6 +134,11 @@ ins1(PyListObject *self, int where, PyObject *v)
PyErr_BadInternalCall(); PyErr_BadInternalCall();
return -1; return -1;
} }
if (self->ob_size == INT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"cannot add more objects to list");
return -1;
}
items = self->ob_item; items = self->ob_item;
NRESIZE(items, PyObject *, self->ob_size+1); NRESIZE(items, PyObject *, self->ob_size+1);
if (items == NULL) { if (items == NULL) {