mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
[3.13] gh-134100: Fix use-after-free in PyImport_ImportModuleLevelObject
(GH-134117) (#134172)
gh-134100: Fix use-after-free in `PyImport_ImportModuleLevelObject` (GH-134117)
(cherry picked from commit 4e9005d32f
)
Co-authored-by: Nico-Posada <102486290+Nico-Posada@users.noreply.github.com>
This commit is contained in:
parent
fd6a602d04
commit
523024499e
3 changed files with 20 additions and 1 deletions
|
@ -3830,15 +3830,17 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
|
|||
}
|
||||
|
||||
final_mod = import_get_module(tstate, to_return);
|
||||
Py_DECREF(to_return);
|
||||
if (final_mod == NULL) {
|
||||
if (!_PyErr_Occurred(tstate)) {
|
||||
_PyErr_Format(tstate, PyExc_KeyError,
|
||||
"%R not in sys.modules as expected",
|
||||
to_return);
|
||||
}
|
||||
Py_DECREF(to_return);
|
||||
goto error;
|
||||
}
|
||||
|
||||
Py_DECREF(to_return);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue