Commit 7fc8a105 authored by Benjamin Peterson's avatar Benjamin Peterson

add missing NULL check

parent 5c863bf9
...@@ -6856,13 +6856,17 @@ posix_fdopen(PyObject *self, PyObject *args) ...@@ -6856,13 +6856,17 @@ posix_fdopen(PyObject *self, PyObject *args)
#if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR) #if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR)
{ {
struct stat buf; struct stat buf;
const char *msg;
PyObject *exc;
if (fstat(fd, &buf) == 0 && S_ISDIR(buf.st_mode)) { if (fstat(fd, &buf) == 0 && S_ISDIR(buf.st_mode)) {
PyMem_FREE(mode); PyMem_FREE(mode);
char *msg = strerror(EISDIR); msg = strerror(EISDIR);
PyObject *exc = PyObject_CallFunction(PyExc_IOError, "(isO)", exc = PyObject_CallFunction(PyExc_IOError, "(isO)",
EISDIR, msg, "<fdopen>"); EISDIR, msg, "<fdopen>");
PyErr_SetObject(PyExc_IOError, exc); if (exc) {
Py_XDECREF(exc); PyErr_SetObject(PyExc_IOError, exc);
Py_DECREF(exc);
}
return NULL; return NULL;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment