[Python-checkins] cpython (2.7): add missing NULL check
benjamin.peterson
python-checkins at python.org
Tue Apr 15 01:57:58 CEST 2014
http://hg.python.org/cpython/rev/3b988a4e7a55
changeset: 90308:3b988a4e7a55
branch: 2.7
user: Benjamin Peterson <benjamin at python.org>
date: Mon Apr 14 19:57:52 2014 -0400
summary:
add missing NULL check
files:
Modules/posixmodule.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -6856,13 +6856,17 @@
#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;
}
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list