This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author alexc
Recipients alexc
Date 2017-03-22.05:52:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490161944.61.0.295678924414.issue29876@psf.upfronthosting.co.za>
In-reply-to
Content
In file _elementtree.c

our static code scanner has reported this case, I think there is a bit similar to http://bugs.python.org/issue29874 (returns NULL when NoMemory)

static PyObject*
subelement(PyObject* self, PyObject* args, PyObject* kw)
{
    PyObject* elem;

    ElementObject* parent;
    PyObject* tag;
    PyObject* attrib = NULL;
    if (!PyArg_ParseTuple(args, "O!O|O!:SubElement",
                          &Element_Type, &parent, &tag,
                          &PyDict_Type, &attrib))
        return NULL;

    if (attrib || kw) {
        attrib = (attrib) ? PyDict_Copy(attrib) : PyDict_New();
        if (!attrib)
            return NULL;
        if (kw)
            PyDict_Update(attrib, kw);
    } else {
        Py_INCREF(Py_None);
        attrib = Py_None;
    }

    elem = element_new(tag, attrib);              // <== element_new could returns a NULL pointer, the followed Py_DECREF(elem) would dereference NULL pointer.

    Py_DECREF(attrib);

    if (element_add_subelement(parent, elem) < 0) {
        Py_DECREF(elem);
        return NULL;
    }
History
Date User Action Args
2017-03-22 05:52:24alexcsetrecipients: + alexc
2017-03-22 05:52:24alexcsetmessageid: <1490161944.61.0.295678924414.issue29876@psf.upfronthosting.co.za>
2017-03-22 05:52:24alexclinkissue29876 messages
2017-03-22 05:52:24alexccreate