summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/zipimport.c3
-rw-r--r--Python/pythonrun.c8
2 files changed, 9 insertions, 2 deletions
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index f5ac10b..e83214c 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -939,6 +939,9 @@ read_directory(PyObject *archive)
header_size = name_size +
PyMarshal_ReadShortFromFile(fp) +
PyMarshal_ReadShortFromFile(fp);
+ if (PyErr_Occurred())
+ goto error;
+
if (fread(dummy, 1, 8, fp) != 8) /* Skip unused fields, avoid fseek */
goto file_error;
file_offset = PyMarshal_ReadLongFromFile(fp) + arc_offset;
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);