Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fixed a use-after-free bug that would occur when an imported module wasn't
in sys.modules after the initial import. Patch by Nico-Posada.
4 changes: 3 additions & 1 deletion Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -3854,15 +3854,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 {
Expand Down
Loading