Skip to content

Commit c8b3427

Browse files
committed
Fix reference leak
1 parent 5bd7291 commit c8b3427

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Modules/_pickle.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,25 +1959,29 @@ whichmodule(PickleState *st, PyObject *global, PyObject *global_name, PyObject *
19591959
extra parameters of __import__ to fix that. */
19601960
module = PyImport_Import(module_name);
19611961
if (module == NULL) {
1962+
Py_DECREF(module_name);
19621963
PyErr_Format(st->PicklingError,
19631964
"Can't pickle %R: import of module %R failed",
19641965
global, module_name);
19651966
return NULL;
19661967
}
19671968
if (check_dotted_path(module, global_name, dotted_path) < 0) {
1969+
Py_DECREF(module_name);
19681970
Py_DECREF(module);
19691971
return NULL;
19701972
}
19711973
PyObject *actual = getattribute(module, dotted_path);
19721974
Py_DECREF(module);
19731975
if (actual == NULL) {
1976+
Py_DECREF(module_name);
19741977
PyErr_Format(st->PicklingError,
19751978
"Can't pickle %R: attribute lookup %S on %S failed",
19761979
global, global_name, module_name);
19771980
return NULL;
19781981
}
19791982
if (actual != global) {
19801983
Py_DECREF(actual);
1984+
Py_DECREF(module_name);
19811985
PyErr_Format(st->PicklingError,
19821986
"Can't pickle %R: it's not the same object as %S.%S",
19831987
global, module_name, global_name);

0 commit comments

Comments
 (0)