Skip to content

Commit 45853b9

Browse files
ashm-devserhiy-storchaka
authored andcommitted
[3.13] gh-140306: Fix memory leaks in cross-interpreter data handling (GH-140307)
(cherry picked from commit f932321) Co-authored-by: Shamil <[email protected]>
1 parent e5ebcab commit 45853b9

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix memory leaks in cross-interpreter channel operations and shared
2+
namespace handling.

Modules/_interpchannelsmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ _channelitem_clear_data(_channelitem *item, int removed)
562562
{
563563
if (item->data != NULL) {
564564
// It was allocated in channel_send().
565-
(void)_release_xid_data(item->data, XID_IGNORE_EXC & XID_FREE);
565+
(void)_release_xid_data(item->data, XID_IGNORE_EXC | XID_FREE);
566566
item->data = NULL;
567567
}
568568

Modules/_interpqueuesmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ _queueitem_clear_data(_queueitem *item)
435435
return;
436436
}
437437
// It was allocated in queue_put().
438-
(void)_release_xid_data(item->data, XID_IGNORE_EXC & XID_FREE);
438+
(void)_release_xid_data(item->data, XID_IGNORE_EXC | XID_FREE);
439439
item->data = NULL;
440440
}
441441

Python/crossinterp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ _release_xid_data(_PyCrossInterpreterData *data, int rawfree)
455455
{
456456
PyObject *exc = PyErr_GetRaisedException();
457457
int res = rawfree
458-
? _PyCrossInterpreterData_Release(data)
459458
: _PyCrossInterpreterData_ReleaseAndRawFree(data);
459+
? _PyCrossInterpreterData_Release(data)
460460
if (res < 0) {
461461
/* The owning interpreter is already destroyed. */
462462
_PyCrossInterpreterData_Clear(NULL, data);

0 commit comments

Comments
 (0)