summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-18 12:56:25 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-18 12:56:25 (GMT)
commit5200f5502407045b747b97168b80d63a3cfafd4f (patch)
treefac1d45532ec623f80bdd245b7ed78fc678f66fb /Python/pythonrun.c
parent50931f41d0837d309289ec36b80951d3c38b30d4 (diff)
downloadcpython-5200f5502407045b747b97168b80d63a3cfafd4f.zip
cpython-5200f5502407045b747b97168b80d63a3cfafd4f.tar.gz
cpython-5200f5502407045b747b97168b80d63a3cfafd4f.tar.bz2
Issue #19428: Handle PyMarshal_Read*() errors in run_pyc_file()
Detect also earlier PyMarshal_Read*() errors in zipimport.
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 992a5a3..a8bd024 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -981,13 +981,17 @@ run_pyc_file(FILE *fp, const char *filename, PyObject *globals,
magic = PyMarshal_ReadLongFromFile(fp);
if (magic != PyImport_GetMagicNumber()) {
- PyErr_SetString(PyExc_RuntimeError,
- "Bad magic number in .pyc file");
+ if (!PyErr_Occurred())
+ PyErr_SetString(PyExc_RuntimeError,
+ "Bad magic number in .pyc file");
return NULL;
}
/* Skip mtime and size */
(void) PyMarshal_ReadLongFromFile(fp);
(void) PyMarshal_ReadLongFromFile(fp);
+ if (PyErr_Occurred())
+ return NULL;
+
v = PyMarshal_ReadLastObjectFromFile(fp);
if (v == NULL || !PyCode_Check(v)) {
Py_XDECREF(v);