summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-07-20 23:53:18 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-07-20 23:53:18 (GMT)
commit8282d749a6353a8ffdc72f63a843cf8b12560aa1 (patch)
treea863e44e936618e7d6cf788499643a6b99f3cfd4 /Python
parent603bd2d374535950720c69efaff04c26c059257e (diff)
parent8c077bc03e3d69404e826a45f5add1f08b85d9a7 (diff)
downloadcpython-8282d749a6353a8ffdc72f63a843cf8b12560aa1.zip
cpython-8282d749a6353a8ffdc72f63a843cf8b12560aa1.tar.gz
cpython-8282d749a6353a8ffdc72f63a843cf8b12560aa1.tar.bz2
Check return value of PyObject_AsFileDescriptor() in _Py_DisplaySourceLine() for error
CID 486768
Diffstat (limited to 'Python')
-rw-r--r--Python/traceback.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/traceback.c b/Python/traceback.c
index 8130d4b..399a174 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -257,6 +257,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 */