Issue #18408: Fix list.extend(), handle list_resize() failure
diff --git a/Objects/listobject.c b/Objects/listobject.c
index b18ef57..0ec70e5 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -871,8 +871,10 @@
}
/* 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;