diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-10 08:31:43 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-02-10 08:31:43 (GMT) |
commit | 5b613dd810b6cd0c44478cf9024db41675f7e02a (patch) | |
tree | 4fd36714617f207d4afbd9e9a816e3c11bc6bc48 /Python/import.c | |
parent | 288ed038aa28b9037e862026d743d4010a615f4e (diff) | |
parent | 48a583b1d83d9c44c9dd9facb9331737518d6618 (diff) | |
download | cpython-5b613dd810b6cd0c44478cf9024db41675f7e02a.zip cpython-5b613dd810b6cd0c44478cf9024db41675f7e02a.tar.gz cpython-5b613dd810b6cd0c44478cf9024db41675f7e02a.tar.bz2 |
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 8ad5b4c..22f94f5 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; |