Issue #18408: Fix list.extend(), handle list_resize() failure

This commit is contained in:
Victor Stinner 2013-07-16 21:45:58 +02:00
parent d1f9942ae3
commit 32fd6eab1e
1 changed files with 4 additions and 2 deletions

View 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;