mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +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
|
@ -1395,18 +1395,13 @@ _PyWarnings_Init(void)
|
|||
goto error;
|
||||
}
|
||||
|
||||
Py_INCREF(st->filters);
|
||||
if (PyModule_AddObject(m, "filters", st->filters) < 0) {
|
||||
if (PyModule_AddObjectRef(m, "filters", st->filters) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
Py_INCREF(st->once_registry);
|
||||
if (PyModule_AddObject(m, "_onceregistry", st->once_registry) < 0) {
|
||||
if (PyModule_AddObjectRef(m, "_onceregistry", st->once_registry) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
Py_INCREF(st->default_action);
|
||||
if (PyModule_AddObject(m, "_defaultaction", st->default_action) < 0) {
|
||||
if (PyModule_AddObjectRef(m, "_defaultaction", st->default_action) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue