Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 94b39ce

Browse files
committed
Issue python#1621: Overflow should not be possible in listextend()
1 parent 5644729 commit 94b39ce

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Objects/listobject.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,9 @@ listextend(PyListObject *self, PyObject *b)
804804
Py_RETURN_NONE;
805805
}
806806
m = Py_SIZE(self);
807+
/* It should not be possible to allocate a list large enough to cause
808+
an overflow on any relevant platform */
809+
assert(m < PY_SSIZE_T_MAX - n);
807810
if (list_resize(self, m + n) < 0) {
808811
Py_DECREF(b);
809812
return NULL;

0 commit comments

Comments
 (0)