mirror of
https://github.com/python/cpython.git
synced 2026-01-06 07:22:09 +00:00
[3.13] gh-130163: Fix a leak in _pickle.c after backporting (GH-130568)
This commit is contained in:
parent
75358a8e95
commit
2ab7e1135a
1 changed files with 7 additions and 0 deletions
|
|
@ -1938,9 +1938,11 @@ whichmodule(PyObject *global, PyObject *dotted_path)
|
|||
i = 0;
|
||||
while (PyDict_Next(modules, &i, &module_name, &module)) {
|
||||
if (_checkmodule(module_name, module, global, dotted_path) == 0) {
|
||||
Py_DECREF(modules);
|
||||
return Py_NewRef(module_name);
|
||||
}
|
||||
if (PyErr_Occurred()) {
|
||||
Py_DECREF(modules);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -1948,6 +1950,7 @@ whichmodule(PyObject *global, PyObject *dotted_path)
|
|||
else {
|
||||
PyObject *iterator = PyObject_GetIter(modules);
|
||||
if (iterator == NULL) {
|
||||
Py_DECREF(modules);
|
||||
return NULL;
|
||||
}
|
||||
while ((module_name = PyIter_Next(iterator))) {
|
||||
|
|
@ -1955,22 +1958,26 @@ whichmodule(PyObject *global, PyObject *dotted_path)
|
|||
if (module == NULL) {
|
||||
Py_DECREF(module_name);
|
||||
Py_DECREF(iterator);
|
||||
Py_DECREF(modules);
|
||||
return NULL;
|
||||
}
|
||||
if (_checkmodule(module_name, module, global, dotted_path) == 0) {
|
||||
Py_DECREF(module);
|
||||
Py_DECREF(iterator);
|
||||
Py_DECREF(modules);
|
||||
return module_name;
|
||||
}
|
||||
Py_DECREF(module);
|
||||
Py_DECREF(module_name);
|
||||
if (PyErr_Occurred()) {
|
||||
Py_DECREF(iterator);
|
||||
Py_DECREF(modules);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
Py_DECREF(iterator);
|
||||
}
|
||||
Py_DECREF(modules);
|
||||
|
||||
/* If no module is found, use __main__. */
|
||||
return &_Py_ID(__main__);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue