Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a584664

Browse files
author
Trent Mick
committed
Check for overflow in list object insertion and raise OverflowError.
see: http://www.python.org/pipermail/python-dev/2000-August/014971.html
1 parent 87df80d commit a584664

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Objects/listobject.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ ins1(PyListObject *self, int where, PyObject *v)
134134
PyErr_BadInternalCall();
135135
return -1;
136136
}
137+
if (self->ob_size == INT_MAX) {
138+
PyErr_SetString(PyExc_OverflowError,
139+
"cannot add more objects to list");
140+
return -1;
141+
}
137142
items = self->ob_item;
138143
NRESIZE(items, PyObject *, self->ob_size+1);
139144
if (items == NULL) {

0 commit comments

Comments
 (0)