diff options
author | Benjamin Peterson <benjamin@python.org> | 2014-04-14 19:57:52 -0400 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2014-04-14 19:57:52 -0400 |
commit | 7fc8a105777fc7899cb6de15fe2d392bf4c361f5 (patch) | |
tree | 766953f5347b6fffd90c460b2a32d56db8df709e | |
parent | 5c863bf93809cefeb4469512eadac291b7046051 (diff) | |
download | cpython-git-7fc8a105777fc7899cb6de15fe2d392bf4c361f5.tar.gz |
add missing NULL check
-rw-r--r-- | Modules/posixmodule.c | 14 |
1 files changed, 9 insertions, 5 deletions
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, "<fdopen>"); - PyErr_SetObject(PyExc_IOError, exc); - Py_XDECREF(exc); + msg = strerror(EISDIR); + exc = PyObject_CallFunction(PyExc_IOError, "(isO)", + EISDIR, msg, "<fdopen>"); + if (exc) { + PyErr_SetObject(PyExc_IOError, exc); + Py_DECREF(exc); + } return NULL; } } |