From 94b39ceb736997eb924dc509ea0ef55f4a19c706 Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Sat, 14 Jan 2017 06:30:37 +0000 Subject: [PATCH] Issue #1621: Overflow should not be possible in listextend() --- Objects/listobject.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Objects/listobject.c b/Objects/listobject.c index dcd7b5efe5b..05dddfc6d7c 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -804,6 +804,9 @@ listextend(PyListObject *self, PyObject *b) Py_RETURN_NONE; } m = Py_SIZE(self); + /* It should not be possible to allocate a list large enough to cause + an overflow on any relevant platform */ + assert(m < PY_SSIZE_T_MAX - n); if (list_resize(self, m + n) < 0) { Py_DECREF(b); return NULL;