From 521556888ab6c69dc47574ef81b8674143d7743d Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 4 Mar 2024 10:46:18 +0100 Subject: [PATCH] gh-116296: Fix refleak in reduce_newobj() corner case (GH-116297) (cherry picked from commit 17c4849981905fb1c9bfbb2b963b6ee12e3efb2c) Co-authored-by: Erlend E. Aasland Co-authored-by: Brandt Bucher --- .../2024-03-04-10-19-51.gh-issue-116296.gvtxyU.rst | 1 + Objects/typeobject.c | 1 + 2 files changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2024-03-04-10-19-51.gh-issue-116296.gvtxyU.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2024-03-04-10-19-51.gh-issue-116296.gvtxyU.rst b/Misc/NEWS.d/next/Core and Builtins/2024-03-04-10-19-51.gh-issue-116296.gvtxyU.rst new file mode 100644 index 00000000000000..0781e9282205d1 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2024-03-04-10-19-51.gh-issue-116296.gvtxyU.rst @@ -0,0 +1 @@ +Fix possible refleak in :meth:`!object.__reduce__` internal error handling. diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 71d20687479aab..7776ae2b735c2b 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -6258,6 +6258,7 @@ reduce_newobj(PyObject *obj) } else { /* args == NULL */ + Py_DECREF(copyreg); Py_DECREF(kwargs); PyErr_BadInternalCall(); return NULL;