[Python-checkins] cpython (merge 3.3 -> default): Check return value of lseek() in _Py_DisplaySourceLine().
christian.heimes
python-checkins at python.org
Sun Jul 21 02:12:55 CEST 2013
http://hg.python.org/cpython/rev/228180598aab
changeset: 84758:228180598aab
parent: 84756:12acefa9ec71
parent: 84757:8fdb83492a58
user: Christian Heimes <christian at cheimes.de>
date: Sun Jul 21 02:12:44 2013 +0200
summary:
Check return value of lseek() in _Py_DisplaySourceLine().
Also use portable SEEK_SET instead of 0.
CID 1040639
files:
Python/traceback.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Python/traceback.c b/Python/traceback.c
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -264,7 +264,13 @@
}
found_encoding = PyTokenizer_FindEncodingFilename(fd, filename);
encoding = (found_encoding != NULL) ? found_encoding : "utf-8";
- lseek(fd, 0, 0); /* Reset position */
+ /* Reset position */
+ if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
+ Py_DECREF(io);
+ Py_DECREF(binary);
+ PyMem_FREE(found_encoding);
+ return PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, filename);
+ }
fob = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "Os", binary, encoding);
Py_DECREF(io);
Py_DECREF(binary);
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list