]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-29876: fix DECREF for NULL value in subelement() (GH-760)
authorXiang Zhang <angwerzx@126.com>
Wed, 22 Mar 2017 06:32:52 +0000 (14:32 +0800)
committerGitHub <noreply@github.com>
Wed, 22 Mar 2017 06:32:52 +0000 (14:32 +0800)
Modules/_elementtree.c

index 7a0aeda63cf3cc42031b0dd430c40038424ddc9d..94dc5b7ca35e334a09625974d332a6f409a6e074 100644 (file)
@@ -524,8 +524,9 @@ subelement(PyObject* self, PyObject* args, PyObject* kw)
     }
 
     elem = element_new(tag, attrib);
-
     Py_DECREF(attrib);
+    if (elem == NULL)
+        return NULL;
 
     if (element_add_subelement(parent, elem) < 0) {
         Py_DECREF(elem);