From: Benjamin Peterson Date: Mon, 14 Apr 2014 23:57:52 +0000 (-0400) Subject: add missing NULL check X-Git-Tag: v2.7.7rc1~59 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7fc8a105777fc7899cb6de15fe2d392bf4c361f5;p=python add missing NULL check --- diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 7a5ef1cab3..cd4672cbb1 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -6856,13 +6856,17 @@ posix_fdopen(PyObject *self, PyObject *args) #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) { struct stat buf; + const char *msg; + PyObject *exc; if (fstat(fd, &buf) == 0 && S_ISDIR(buf.st_mode)) { PyMem_FREE(mode); - char *msg = strerror(EISDIR); - PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(isO)", - EISDIR, msg, ""); - PyErr_SetObject(PyExc_IOError, exc); - Py_XDECREF(exc); + msg = strerror(EISDIR); + exc = PyObject_CallFunction(PyExc_IOError, "(isO)", + EISDIR, msg, ""); + if (exc) { + PyErr_SetObject(PyExc_IOError, exc); + Py_DECREF(exc); + } return NULL; } }