]> granicus.if.org Git - python/commitdiff
Issue #1621: Overflow should not be possible in listextend()
authorMartin Panter <vadmium+py@gmail.com>
Sat, 14 Jan 2017 06:30:37 +0000 (06:30 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Sat, 14 Jan 2017 06:30:37 +0000 (06:30 +0000)
Objects/listobject.c

index dcd7b5efe5b0fe7bb0e4c4b20b233f7e7a92b6ed..05dddfc6d7ccb3f40b4c7ce82466b42ef284631c 100644 (file)
@@ -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;