gh-116296: Fix refleak in reduce_newobj() corner case (#116297)

Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
This commit is contained in:
Erlend E. Aasland 2024-03-04 10:46:18 +01:00 committed by GitHub
parent 1dce0073da
commit 17c4849981
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 0 deletions

View File

@ -0,0 +1 @@
Fix possible refleak in :meth:`!object.__reduce__` internal error handling.

View File

@ -6549,6 +6549,7 @@ reduce_newobj(PyObject *obj)
} }
else { else {
/* args == NULL */ /* args == NULL */
Py_DECREF(copyreg);
Py_DECREF(kwargs); Py_DECREF(kwargs);
PyErr_BadInternalCall(); PyErr_BadInternalCall();
return NULL; return NULL;