Skip to content

Commit

Permalink
gh-122704: Fix reference leak in Modules/_pickle.c (GH-122705)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eclips4 committed Aug 6, 2024
1 parent b0c48b8 commit 94a4bd7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Modules/_pickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -1974,13 +1976,15 @@ 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) {
Py_DECREF(actual);
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);
Expand Down

0 comments on commit 94a4bd7

Please sign in to comment.