]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-146245: Fix reference and buffer leaks via audit hook in socket module...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 22 Mar 2026 11:55:13 +0000 (12:55 +0100)
committerGitHub <noreply@github.com>
Sun, 22 Mar 2026 11:55:13 +0000 (11:55 +0000)
(cherry picked from commit c30fae4bea9f9ba07833e97eb542754c26610765)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
Misc/NEWS.d/next/Core_and_Builtins/2026-03-21-08-48-25.gh-issue-146245.cqM3_4.rst [new file with mode: 0644]
Modules/socketmodule.c

diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2026-03-21-08-48-25.gh-issue-146245.cqM3_4.rst b/Misc/NEWS.d/next/Core_and_Builtins/2026-03-21-08-48-25.gh-issue-146245.cqM3_4.rst
new file mode 100644 (file)
index 0000000..f52eaa0
--- /dev/null
@@ -0,0 +1 @@
+Fixed reference leaks in :mod:`socket` when audit hooks raise exceptions in :func:`socket.getaddrinfo` and :meth:`!socket.sendto`.
index 563a930bbcd7ad70c01ddec3c5433e642770f333..c415c93ccb8c9cabb3914ed7e9a51cf534395199 100644 (file)
@@ -4795,6 +4795,7 @@ sock_sendto(PyObject *self, PyObject *args)
     }
 
     if (PySys_Audit("socket.sendto", "OO", s, addro) < 0) {
+        PyBuffer_Release(&pbuf);
         return NULL;
     }
 
@@ -6965,7 +6966,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
 
     if (PySys_Audit("socket.getaddrinfo", "OOiii",
                     hobj, pobj, family, socktype, protocol) < 0) {
-        return NULL;
+        goto err;
     }
 
     memset(&hints, 0, sizeof(hints));