Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 60a0c71

Browse files
committed
Issue #16076: check for return value of PyTuple_New for args (following
Coverity report) and cleanup code.
2 parents 0f3735b + 799e3ed commit 60a0c71

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

Modules/_elementtree.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -950,19 +950,22 @@ element_setstate_from_Python(ElementObject *self, PyObject *state)
950950
PICKLED_TAIL, PICKLED_CHILDREN, 0};
951951
PyObject *args;
952952
PyObject *tag, *attrib, *text, *tail, *children;
953-
int error;
953+
PyObject *retval;
954954

955-
/* More instance dict members than we know to handle? */
956955
tag = attrib = text = tail = children = NULL;
957956
args = PyTuple_New(0);
958-
error = ! PyArg_ParseTupleAndKeywords(args, state, "|$OOOOO", kwlist, &tag,
959-
&attrib, &text, &tail, &children);
960-
Py_DECREF(args);
961-
if (error)
957+
if (!args)
962958
return NULL;
959+
960+
if (PyArg_ParseTupleAndKeywords(args, state, "|$OOOOO", kwlist, &tag,
961+
&attrib, &text, &tail, &children))
962+
retval = element_setstate_from_attributes(self, tag, attrib, text,
963+
tail, children);
963964
else
964-
return element_setstate_from_attributes(self, tag, attrib, text,
965-
tail, children);
965+
retval = NULL;
966+
967+
Py_DECREF(args);
968+
return retval;
966969
}
967970

968971
static PyObject *

0 commit comments

Comments
 (0)