[3.13] gh-140306: Fix memory leaks in cross-interpreter data handling (GH-140307) (GH-140357)

(cherry picked from commit f9323213c9)

Co-authored-by: Shamil <ashm.tech@proton.me>
This commit is contained in:
Serhiy Storchaka 2025-10-20 13:13:15 +03:00 committed by GitHub
parent e5ebcabc6b
commit d7473f7a47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 6 additions and 4 deletions

View file

@ -455,8 +455,8 @@ _release_xid_data(_PyCrossInterpreterData *data, int rawfree)
{
PyObject *exc = PyErr_GetRaisedException();
int res = rawfree
? _PyCrossInterpreterData_Release(data)
: _PyCrossInterpreterData_ReleaseAndRawFree(data);
? _PyCrossInterpreterData_ReleaseAndRawFree(data)
: _PyCrossInterpreterData_Release(data);
if (res < 0) {
/* The owning interpreter is already destroyed. */
_PyCrossInterpreterData_Clear(NULL, data);