mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
bpo-1635741: Fix ref leak in _PyWarnings_Init() error path (GH-23151)
Replace PyModule_AddObject() with PyModule_AddObjectRef() in the _warnings module to fix a reference leak on error. Use also PyModule_AddObjectRef() in importdl.c.
This commit is contained in:
parent
18ce7f1d0a
commit
58ca33b467
2 changed files with 5 additions and 11 deletions
|
@ -220,10 +220,9 @@ _PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *fp)
|
|||
def->m_base.m_init = p0;
|
||||
|
||||
/* Remember the filename as the __file__ attribute */
|
||||
if (PyModule_AddObject(m, "__file__", path) < 0)
|
||||
if (PyModule_AddObjectRef(m, "__file__", path) < 0) {
|
||||
PyErr_Clear(); /* Not important enough to report */
|
||||
else
|
||||
Py_INCREF(path);
|
||||
}
|
||||
|
||||
PyObject *modules = PyImport_GetModuleDict();
|
||||
if (_PyImport_FixupExtensionObject(m, name_unicode, path, modules) < 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue