summaryrefslogtreecommitdiffstats
path: root/Modules/_elementtree.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-11 21:01:36 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-11 21:01:36 (GMT)
commit5f0af23f5ebd3d1ad6eea63bad238d7168ee61a2 (patch)
treeeb8713efee991f3113eee88f9783099bf2c3ad0e /Modules/_elementtree.c
parent68c8ea25f1b4354cc073d2ebcd5f8cc8acef0b42 (diff)
downloadcpython-5f0af23f5ebd3d1ad6eea63bad238d7168ee61a2.zip
cpython-5f0af23f5ebd3d1ad6eea63bad238d7168ee61a2.tar.gz
cpython-5f0af23f5ebd3d1ad6eea63bad238d7168ee61a2.tar.bz2
Issue #18408: _elementtree.c now handles create_extra() failure
Diffstat (limited to 'Modules/_elementtree.c')
-rw-r--r--Modules/_elementtree.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 377e88e..1957abf 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);