diff options
author | Christian Heimes <christian@cheimes.de> | 2013-07-21 01:53:10 +0200 |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2013-07-21 01:53:10 +0200 |
commit | fd58e214588f9aa434d4eb0d7b9a080da135adb0 (patch) | |
tree | 2a9d6654bae192e3a6c044093d3661beb18b5293 /Python/traceback.c | |
parent | 1cb04c0bb123b34869633258a771156e9c6444ed (diff) | |
download | cpython-fd58e214588f9aa434d4eb0d7b9a080da135adb0.tar.gz |
Check return value of PyObject_AsFileDescriptor() in _Py_DisplaySourceLine() for error
CID 486768
Diffstat (limited to 'Python/traceback.c')
-rw-r--r-- | Python/traceback.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/traceback.c b/Python/traceback.c index b928902ef0..c37aab0a9c 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -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 */ |