From: svelankar Date: Thu, 9 Mar 2017 05:27:48 +0000 (-0500) Subject: Issue #29682:Possible missing NULL check in pyexpat (#573) X-Git-Tag: v2.7.14rc1~252 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de1c7d52527e1d84c131f4801d2dc3d0236b5b25;p=thirdparty%2FPython%2Fcpython.git Issue #29682:Possible missing NULL check in pyexpat (#573) --- diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index a95c3885fa2c..7f95bb80e03f 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -1312,6 +1312,13 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern) else { self->itself = XML_ParserCreate(encoding); } + if (self->itself == NULL) { + PyErr_SetString(PyExc_RuntimeError, + "XML_ParserCreate failed"); + Py_DECREF(self); + return NULL; + } + #if ((XML_MAJOR_VERSION >= 2) && (XML_MINOR_VERSION >= 1)) || defined(XML_HAS_SET_HASH_SALT) /* This feature was added upstream in libexpat 2.1.0. Our expat copy * has a backport of this feature where we also define XML_HAS_SET_HASH_SALT @@ -1326,12 +1333,6 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern) #else PyObject_GC_Init(self); #endif - if (self->itself == NULL) { - PyErr_SetString(PyExc_RuntimeError, - "XML_ParserCreate failed"); - Py_DECREF(self); - return NULL; - } XML_SetUserData(self->itself, (void *)self); #ifdef Py_USING_UNICODE XML_SetUnknownEncodingHandler(self->itself,