Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 94a4bd7

Browse files
authored
gh-122704: Fix reference leak in Modules/_pickle.c (GH-122705)
1 parent b0c48b8 commit 94a4bd7

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
@@ -1962,9 +1962,11 @@ whichmodule(PickleState *st, PyObject *global, PyObject *global_name, PyObject *
19621962
PyErr_Format(st->PicklingError,
19631963
"Can't pickle %R: import of module %R failed",
19641964
global, module_name);
1965+
Py_DECREF(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
}
@@ -1974,13 +1976,15 @@ whichmodule(PickleState *st, PyObject *global, PyObject *global_name, PyObject *
19741976
PyErr_Format(st->PicklingError,
19751977
"Can't pickle %R: attribute lookup %S on %S failed",
19761978
global, global_name, module_name);
1979+
Py_DECREF(module_name);
19771980
return NULL;
19781981
}
19791982
if (actual != global) {
19801983
Py_DECREF(actual);
19811984
PyErr_Format(st->PicklingError,
19821985
"Can't pickle %R: it's not the same object as %S.%S",
19831986
global, module_name, global_name);
1987+
Py_DECREF(module_name);
19841988
return NULL;
19851989
}
19861990
Py_DECREF(actual);

0 commit comments

Comments
 (0)