diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-10 10:31:20 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-10 10:31:20 +0200 |
commit | 397ca3e0af84fb1ea32229aff143db8bd69e266c (patch) | |
tree | f4a6bb6637eba94e59eb9aac706db90fd4e19140 /Python/import.c | |
parent | 4e214c5025aeeeb69562dd0c46ae0918881d0bae (diff) | |
download | cpython-397ca3e0af84fb1ea32229aff143db8bd69e266c.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.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c index edf030d87a..0b843dafd3 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; |