summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-02-10 08:31:20 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-02-10 08:31:20 (GMT)
commit48a583b1d83d9c44c9dd9facb9331737518d6618 (patch)
treea9bf8edac7c1daa4bc1aac074f403ccbb2b22b49
parentc04fb56e36999a4162e6ccfe1f9357100abaee99 (diff)
downloadcpython-48a583b1d83d9c44c9dd9facb9331737518d6618.zip
cpython-48a583b1d83d9c44c9dd9facb9331737518d6618.tar.gz
cpython-48a583b1d83d9c44c9dd9facb9331737518d6618.tar.bz2
Issue #25698: Prevent possible replacing imported module with the empty one
if the stack is too deep.
-rw-r--r--Python/import.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c
index edf030d..0b843da 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -671,9 +671,13 @@ PyImport_AddModuleObject(PyObject *name)
PyObject *modules = PyImport_GetModuleDict();
PyObject *m;
- if ((m = PyDict_GetItem(modules, name)) != NULL &&
- PyModule_Check(m))
+ if ((m = PyDict_GetItemWithError(modules, name)) != NULL &&
+ PyModule_Check(m)) {
return m;
+ }
+ if (PyErr_Occurred()) {
+ return NULL;
+ }
m = PyModule_NewObject(name);
if (m == NULL)
return NULL;