]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules... 3.14
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 17 May 2026 10:35:27 +0000 (12:35 +0200)
committerGitHub <noreply@github.com>
Sun, 17 May 2026 10:35:27 +0000 (10:35 +0000)
gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (GH-149922)
(cherry picked from commit acefff95eab3db6b7cf837f3ce2707bbf9199376)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
Misc/NEWS.d/next/Library/2026-05-16-21-08-33.gh-issue-149921.I1yNML.rst [new file with mode: 0644]
Modules/_interpchannelsmodule.c
Modules/_interpqueuesmodule.c

diff --git a/Misc/NEWS.d/next/Library/2026-05-16-21-08-33.gh-issue-149921.I1yNML.rst b/Misc/NEWS.d/next/Library/2026-05-16-21-08-33.gh-issue-149921.I1yNML.rst
new file mode 100644 (file)
index 0000000..113bd1a
--- /dev/null
@@ -0,0 +1,2 @@
+Fix reference leaks in error paths of the :mod:`!_interpchannels` and
+:mod:`!_interpqueues` extension modules.
index 2933332ad465d4080763116822f49f5880d42abf..be3a932ca03d3951eb9c0a35287c24d686343dd5 100644 (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);
index 872495d32fbf8ff7cee86cde1d269dcfb17612f2..4efeadde3d01f31633eb77b522f6dc73be6a5f71 100644 (file)
@@ -1358,6 +1358,7 @@ _queueobj_from_xid(_PyXIData_t *data)
     if (mod == NULL) {
         mod = PyImport_ImportModule(MODULE_NAME_STR);
         if (mod == NULL) {
+            Py_DECREF(qidobj);
             return NULL;
         }
     }