From 32fd6eab1e9e3304b504943b425c7d9ba65bba66 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 16 Jul 2013 21:45:58 +0200 Subject: [PATCH] Issue #18408: Fix list.extend(), handle list_resize() failure --- Objects/listobject.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index b18ef5763af..0ec70e587af 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -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;