[Python-checkins] r68752 - python/branches/io-c/Modules/_iobase.c

amaury.forgeotdarc python-checkins at python.org
Mon Jan 19 00:05:43 CET 2009


Author: amaury.forgeotdarc
Date: Mon Jan 19 00:05:43 2009
New Revision: 68752

Log:
Fix a segfault when e.g a BufferedReader is created with a FileIO in 
read mode.


Modified:
   python/branches/io-c/Modules/_iobase.c

Modified: python/branches/io-c/Modules/_iobase.c
==============================================================================
--- python/branches/io-c/Modules/_iobase.c	(original)
+++ python/branches/io-c/Modules/_iobase.c	Mon Jan 19 00:05:43 2009
@@ -125,6 +125,8 @@
     /* This gets the derived attribute, which is *not* __IOBase_closed
        in most cases! */
     res = PyObject_GetAttr(self, _PyIO_str_closed);
+    if (res == NULL)
+        return 0;
     closed = PyObject_IsTrue(res);
     Py_DECREF(res);
     return closed;
@@ -221,6 +223,7 @@
     if (res != Py_True) {
         Py_CLEAR(res);
         PyErr_SetString(PyExc_IOError, "File or stream is not seekable.");
+        return NULL;
     }
     if (args == Py_True) {
         Py_DECREF(res);
@@ -249,6 +252,7 @@
     if (res != Py_True) {
         Py_CLEAR(res);
         PyErr_SetString(PyExc_IOError, "File or stream is not readable.");
+        return NULL;
     }
     if (args == Py_True) {
         Py_DECREF(res);
@@ -277,6 +281,7 @@
     if (res != Py_True) {
         Py_CLEAR(res);
         PyErr_SetString(PyExc_IOError, "File or stream is not writable.");
+        return NULL;
     }
     if (args == Py_True) {
         Py_DECREF(res);


More information about the Python-checkins mailing list