diff options
author | Christian Heimes <christian@cheimes.de> | 2013-07-20 23:53:10 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2013-07-20 23:53:10 (GMT) |
commit | 8c077bc03e3d69404e826a45f5add1f08b85d9a7 (patch) | |
tree | 8eb657cd84425bc24c3efffd3a0385c06dac8019 /Python | |
parent | a6404ad43c11d04909a9e01f85559e1b52e616b4 (diff) | |
download | cpython-8c077bc03e3d69404e826a45f5add1f08b85d9a7.zip cpython-8c077bc03e3d69404e826a45f5add1f08b85d9a7.tar.gz cpython-8c077bc03e3d69404e826a45f5add1f08b85d9a7.tar.bz2 |
Check return value of PyObject_AsFileDescriptor() in _Py_DisplaySourceLine() for error
CID 486768
Diffstat (limited to 'Python')
-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 b928902..c37aab0 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 */ |