]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-122704: Fix reference leak in Modules/_pickle.c (GH-122705)
authorKirill Podoprigora <kirill.bast9@mail.ru>
Tue, 6 Aug 2024 05:57:36 +0000 (08:57 +0300)
committerGitHub <noreply@github.com>
Tue, 6 Aug 2024 05:57:36 +0000 (08:57 +0300)
Modules/_pickle.c

index 5d9ee8cb6c679d7d861acb986054963b1d7d6281..dc0ef0a184d2058161a95549f7f8ae6eadbe0718 100644 (file)
@@ -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);