mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #25698: Prevent possible replacing imported module with the empty one
if the stack is too deep.
This commit is contained in:
parent
c04fb56e36
commit
48a583b1d8
1 changed files with 6 additions and 2 deletions
|
@ -671,9 +671,13 @@ PyImport_AddModuleObject(PyObject *name)
|
||||||
PyObject *modules = PyImport_GetModuleDict();
|
PyObject *modules = PyImport_GetModuleDict();
|
||||||
PyObject *m;
|
PyObject *m;
|
||||||
|
|
||||||
if ((m = PyDict_GetItem(modules, name)) != NULL &&
|
if ((m = PyDict_GetItemWithError(modules, name)) != NULL &&
|
||||||
PyModule_Check(m))
|
PyModule_Check(m)) {
|
||||||
return m;
|
return m;
|
||||||
|
}
|
||||||
|
if (PyErr_Occurred()) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
m = PyModule_NewObject(name);
|
m = PyModule_NewObject(name);
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue