summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2013-01-12 13:43:08 (GMT)
committerEli Bendersky <eliben@gmail.com>2013-01-12 13:43:08 (GMT)
commit60a0c710311b29539f8c8a6404a51b21f44b1e43 (patch)
treecfff1424f7dad127102ebd741c07a58ac016d2a4 /Modules
parent0f3735b8f0ba46556d4f28e8a2cc83ae7519a1d2 (diff)
parent799e3edaf762baafaff8386dc8d5cdf078f80805 (diff)
downloadcpython-60a0c710311b29539f8c8a6404a51b21f44b1e43.zip
cpython-60a0c710311b29539f8c8a6404a51b21f44b1e43.tar.gz
cpython-60a0c710311b29539f8c8a6404a51b21f44b1e43.tar.bz2
Issue #16076: check for return value of PyTuple_New for args (following
Coverity report) and cleanup code.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_elementtree.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 8cc9803..3f357b0 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -950,19 +950,22 @@ element_setstate_from_Python(ElementObject *self, PyObject *state)
PICKLED_TAIL, PICKLED_CHILDREN, 0};
PyObject *args;
PyObject *tag, *attrib, *text, *tail, *children;
- int error;
+ PyObject *retval;
- /* More instance dict members than we know to handle? */
tag = attrib = text = tail = children = NULL;
args = PyTuple_New(0);
- error = ! PyArg_ParseTupleAndKeywords(args, state, "|$OOOOO", kwlist, &tag,
- &attrib, &text, &tail, &children);
- Py_DECREF(args);
- if (error)
+ if (!args)
return NULL;
+
+ if (PyArg_ParseTupleAndKeywords(args, state, "|$OOOOO", kwlist, &tag,
+ &attrib, &text, &tail, &children))
+ retval = element_setstate_from_attributes(self, tag, attrib, text,
+ tail, children);
else
- return element_setstate_from_attributes(self, tag, attrib, text,
- tail, children);
+ retval = NULL;
+
+ Py_DECREF(args);
+ return retval;
}
static PyObject *