From: Charles Machalow Date: Sat, 13 May 2023 20:45:36 +0000 (-0700) Subject: gh-104454: Fix refleak in AttributeError_reduce (#104455) X-Git-Tag: v3.12.0b1~131 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7d2deafb73237a2175971a26cfb544974661de4b;p=thirdparty%2FPython%2Fcpython.git gh-104454: Fix refleak in AttributeError_reduce (#104455) * Fix the reference leak introduced by https://github.com/python/cpython/issues/103333 Co-authored-by: Kirill Podoprigora --- diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 59c63f4aa449..a8d4e3a696ce 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -2324,7 +2324,9 @@ AttributeError_reduce(PyAttributeErrorObject *self, PyObject *Py_UNUSED(ignored) return NULL; } - return PyTuple_Pack(3, Py_TYPE(self), self->args, state); + PyObject *return_value = PyTuple_Pack(3, Py_TYPE(self), self->args, state); + Py_DECREF(state); + return return_value; } static PyMemberDef AttributeError_members[] = {