]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-104454: Fix refleak in AttributeError_reduce (#104455)
authorCharles Machalow <csm10495@gmail.com>
Sat, 13 May 2023 20:45:36 +0000 (13:45 -0700)
committerGitHub <noreply@github.com>
Sat, 13 May 2023 20:45:36 +0000 (13:45 -0700)
* Fix the reference leak introduced by https://github.com/python/cpython/issues/103333

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
Objects/exceptions.c

index 59c63f4aa44958c7ac7b319907ffd339f8f0da0b..a8d4e3a696ce8e216662e6011f2f67218ea6f961 100644 (file)
@@ -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[] = {