Skip to content

Commit 42ff9b4

Browse files
miss-islingtonaisk
andauthored
[3.15] gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (GH-149922) (#149943)
gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (GH-149922) (cherry picked from commit acefff9) Co-authored-by: AN Long <aisk@users.noreply.github.com>
1 parent bdc44c5 commit 42ff9b4

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
@@ -2586,6 +2586,7 @@ static PyObject *
25862586
_channelid_from_xid(_PyXIData_t *data)
25872587
{
25882588
struct _channelid_xid *xid = (struct _channelid_xid *)_PyXIData_DATA(data);
2589+
PyObject *cidobj = NULL;
25892590

25902591
// It might not be imported yet, so we can't use _get_current_module().
25912592
PyObject *mod = PyImport_ImportModule(MODULE_NAME_STR);
@@ -2595,11 +2596,10 @@ _channelid_from_xid(_PyXIData_t *data)
25952596
assert(mod != Py_None);
25962597
module_state *state = get_module_state(mod);
25972598
if (state == NULL) {
2598-
return NULL;
2599+
goto done;
25992600
}
26002601

26012602
// Note that we do not preserve the "resolve" flag.
2602-
PyObject *cidobj = NULL;
26032603
int err = newchannelid(state->ChannelIDType, xid->cid, xid->end,
26042604
_global_channels(), 0, 0,
26052605
(channelid **)&cidobj);

Modules/_interpqueuesmodule.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,7 @@ _queueobj_from_xid(_PyXIData_t *data)
13631363
if (mod == NULL) {
13641364
mod = PyImport_ImportModule(MODULE_NAME_STR);
13651365
if (mod == NULL) {
1366+
Py_DECREF(qidobj);
13661367
return NULL;
13671368
}
13681369
}

0 commit comments

Comments
 (0)