]> granicus.if.org Git - python/commitdiff
Issue #18408: Fix list.extend(), handle list_resize() failure
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 16 Jul 2013 19:45:58 +0000 (21:45 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 16 Jul 2013 19:45:58 +0000 (21:45 +0200)
Objects/listobject.c

index b18ef5763afee5bf9c0a7e3d2f0f2e6b958e95cc..0ec70e587af815b330fe4c3fc4ca0a9b7902df0c 100644 (file)
@@ -871,8 +871,10 @@ listextend(PyListObject *self, PyObject *b)
     }
 
     /* Cut back result list if initial guess was too large. */
-    if (Py_SIZE(self) < self->allocated)
-        list_resize(self, Py_SIZE(self));  /* shrinking can't fail */
+    if (Py_SIZE(self) < self->allocated) {
+        if (list_resize(self, Py_SIZE(self)) < 0)
+            goto error;
+    }
 
     Py_DECREF(it);
     Py_RETURN_NONE;