From: Victor Stinner Date: Thu, 11 Jul 2013 21:01:36 +0000 (+0200) Subject: Issue #18408: _elementtree.c now handles create_extra() failure X-Git-Tag: v3.4.0a1~249 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f0af23f5ebd3d1ad6eea63bad238d7168ee61a2;p=python Issue #18408: _elementtree.c now handles create_extra() failure --- diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c index 377e88e721..1957abfafd 100644 --- a/Modules/_elementtree.c +++ b/Modules/_elementtree.c @@ -374,8 +374,10 @@ element_resize(ElementObject* self, int extra) /* make sure self->children can hold the given number of extra elements. set an exception and return -1 if allocation failed */ - if (!self->extra) - create_extra(self, NULL); + if (!self->extra) { + if (create_extra(self, NULL) < 0) + return -1; + } size = self->extra->length + extra; @@ -1267,8 +1269,10 @@ element_insert(ElementObject* self, PyObject* args) &Element_Type, &element)) return NULL; - if (!self->extra) - create_extra(self, NULL); + if (!self->extra) { + if (create_extra(self, NULL) < 0) + return NULL; + } if (index < 0) { index += self->extra->length; @@ -1409,8 +1413,10 @@ element_set(ElementObject* self, PyObject* args) if (!PyArg_ParseTuple(args, "OO:set", &key, &value)) return NULL; - if (!self->extra) - create_extra(self, NULL); + if (!self->extra) { + if (create_extra(self, NULL) < 0) + return NULL; + } attrib = element_get_attrib(self); if (!attrib) @@ -1525,8 +1531,10 @@ element_ass_subscr(PyObject* self_, PyObject* item, PyObject* value) PyObject* recycle = NULL; PyObject* seq = NULL; - if (!self->extra) - create_extra(self, NULL); + if (!self->extra) { + if (create_extra(self, NULL) < 0) + return -1; + } if (PySlice_GetIndicesEx(item, self->extra->length, @@ -1756,8 +1764,10 @@ element_getattro(ElementObject* self, PyObject* nameobj) res = element_get_tail(self); } else if (strcmp(name, "attrib") == 0) { PyErr_Clear(); - if (!self->extra) - create_extra(self, NULL); + if (!self->extra) { + if (create_extra(self, NULL) < 0) + return NULL; + } res = element_get_attrib(self); } @@ -1790,8 +1800,10 @@ element_setattro(ElementObject* self, PyObject* nameobj, PyObject* value) self->tail = value; Py_INCREF(self->tail); } else if (strcmp(name, "attrib") == 0) { - if (!self->extra) - create_extra(self, NULL); + if (!self->extra) { + if (create_extra(self, NULL) < 0) + return -1; + } Py_DECREF(self->extra->attrib); self->extra->attrib = value; Py_INCREF(self->extra->attrib);