mirror of https://github.com/python/cpython
gh-122704: Fix reference leak in Modules/_pickle.c (GH-122705)
This commit is contained in:
parent
b0c48b8fd8
commit
94a4bd79a7
|
@ -1962,9 +1962,11 @@ whichmodule(PickleState *st, PyObject *global, PyObject *global_name, PyObject *
|
|||
PyErr_Format(st->PicklingError,
|
||||
"Can't pickle %R: import of module %R failed",
|
||||
global, module_name);
|
||||
Py_DECREF(module_name);
|
||||
return NULL;
|
||||
}
|
||||
if (check_dotted_path(module, global_name, dotted_path) < 0) {
|
||||
Py_DECREF(module_name);
|
||||
Py_DECREF(module);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1974,6 +1976,7 @@ whichmodule(PickleState *st, PyObject *global, PyObject *global_name, PyObject *
|
|||
PyErr_Format(st->PicklingError,
|
||||
"Can't pickle %R: attribute lookup %S on %S failed",
|
||||
global, global_name, module_name);
|
||||
Py_DECREF(module_name);
|
||||
return NULL;
|
||||
}
|
||||
if (actual != global) {
|
||||
|
@ -1981,6 +1984,7 @@ whichmodule(PickleState *st, PyObject *global, PyObject *global_name, PyObject *
|
|||
PyErr_Format(st->PicklingError,
|
||||
"Can't pickle %R: it's not the same object as %S.%S",
|
||||
global, module_name, global_name);
|
||||
Py_DECREF(module_name);
|
||||
return NULL;
|
||||
}
|
||||
Py_DECREF(actual);
|
||||
|
|
Loading…
Reference in New Issue