gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (#149922)

This commit is contained in:
AN Long 2026-05-17 19:09:19 +09:00 committed by GitHub
parent e62a61177f
commit acefff95ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 2 deletions

View file

@ -0,0 +1,2 @@
Fix reference leaks in error paths of the :mod:`!_interpchannels` and
:mod:`!_interpqueues` extension modules.

View file

@ -2586,6 +2586,7 @@ static PyObject *
_channelid_from_xid(_PyXIData_t *data)
{
struct _channelid_xid *xid = (struct _channelid_xid *)_PyXIData_DATA(data);
PyObject *cidobj = NULL;
// It might not be imported yet, so we can't use _get_current_module().
PyObject *mod = PyImport_ImportModule(MODULE_NAME_STR);
@ -2595,11 +2596,10 @@ _channelid_from_xid(_PyXIData_t *data)
assert(mod != Py_None);
module_state *state = get_module_state(mod);
if (state == NULL) {
return NULL;
goto done;
}
// Note that we do not preserve the "resolve" flag.
PyObject *cidobj = NULL;
int err = newchannelid(state->ChannelIDType, xid->cid, xid->end,
_global_channels(), 0, 0,
(channelid **)&cidobj);

View file

@ -1363,6 +1363,7 @@ _queueobj_from_xid(_PyXIData_t *data)
if (mod == NULL) {
mod = PyImport_ImportModule(MODULE_NAME_STR);
if (mod == NULL) {
Py_DECREF(qidobj);
return NULL;
}
}