summaryrefslogtreecommitdiff
path: root/Python/import.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-02-10 10:31:43 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-02-10 10:31:43 +0200
commit7e1b46ee84aaa9957b200bd0e6eb5bf287ed59bc (patch)
tree98557e0ec98f63ad7a7ba80935d82582e97f181c /Python/import.c
parent71201e3f6b9e29fa734d7c515ffa2b7b96bb59ec (diff)
parent397ca3e0af84fb1ea32229aff143db8bd69e266c (diff)
downloadcpython-7e1b46ee84aaa9957b200bd0e6eb5bf287ed59bc.tar.gz
Issue #25698: Prevent possible replacing imported module with the empty one
if the stack is too deep.
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c
index 8ad5b4c167..22f94f5f18 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;