]> granicus.if.org Git - python/commitdiff
Check return value of PyObject_AsFileDescriptor() in _Py_DisplaySourceLine() for...
authorChristian Heimes <christian@cheimes.de>
Sat, 20 Jul 2013 23:53:10 +0000 (01:53 +0200)
committerChristian Heimes <christian@cheimes.de>
Sat, 20 Jul 2013 23:53:10 +0000 (01:53 +0200)
CID 486768

Python/traceback.c

index b928902ef02447ff62786d57de3661e042200b47..c37aab0a9c11bb968b91a1f22b3d15892cba236b 100644 (file)
@@ -255,6 +255,11 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
 
     /* use the right encoding to decode the file as unicode */
     fd = PyObject_AsFileDescriptor(binary);
+    if (fd < 0) {
+        Py_DECREF(io);
+        Py_DECREF(binary);
+        return NULL;
+    }
     found_encoding = PyTokenizer_FindEncodingFilename(fd, filename);
     encoding = (found_encoding != NULL) ? found_encoding : "utf-8";
     lseek(fd, 0, 0); /* Reset position */