From 7fc8a105777fc7899cb6de15fe2d392bf4c361f5 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 14 Apr 2014 19:57:52 -0400 Subject: [PATCH] add missing NULL check --- Modules/posixmodule.c | 14 +++++++++----- 1 file 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, ""); - 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; } } -- 2.50.1