Skip to content

Commit 5531c77

Browse files
authored
[3.13] gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (GH-149922) (#149954)
(cherry picked from commit acefff9)
1 parent b2b35ba commit 5531c77

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix reference leaks in error paths of the :mod:`!_interpchannels` and
2+
:mod:`!_interpqueues` extension modules.

Modules/_interpchannelsmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,6 +2553,7 @@ _channelid_from_xid(_PyCrossInterpreterData *data)
25532553
{
25542554
struct _channelid_xid *xid = \
25552555
(struct _channelid_xid *)_PyCrossInterpreterData_DATA(data);
2556+
PyObject *cidobj = NULL;
25562557

25572558
// It might not be imported yet, so we can't use _get_current_module().
25582559
PyObject *mod = PyImport_ImportModule(MODULE_NAME_STR);
@@ -2562,11 +2563,10 @@ _channelid_from_xid(_PyCrossInterpreterData *data)
25622563
assert(mod != Py_None);
25632564
module_state *state = get_module_state(mod);
25642565
if (state == NULL) {
2565-
return NULL;
2566+
goto done;
25662567
}
25672568

25682569
// Note that we do not preserve the "resolve" flag.
2569-
PyObject *cidobj = NULL;
25702570
int err = newchannelid(state->ChannelIDType, xid->cid, xid->end,
25712571
_global_channels(), 0, 0,
25722572
(channelid **)&cidobj);

Modules/_interpqueuesmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,7 @@ _queueobj_from_xid(_PyCrossInterpreterData *data)
13551355
// XXX import it?
13561356
PyErr_SetString(PyExc_RuntimeError,
13571357
MODULE_NAME_STR " module not imported yet");
1358+
Py_DECREF(qidobj);
13581359
return NULL;
13591360
}
13601361

0 commit comments

Comments
 (0)