https://github.com/python/cpython/commit/2f1e341b2898fd5bb9c8800ccf6646dbe214f519 commit: 2f1e341b2898fd5bb9c8800ccf6646dbe214f519 branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: serhiy-storchaka <[email protected]> date: 2026-03-22T11:51:54Z summary:
[3.13] gh-146245: Fix reference and buffer leaks via audit hook in socket module (GH-146248) (GH-146275) (cherry picked from commit c30fae4bea9f9ba07833e97eb542754c26610765) Co-authored-by: AN Long <[email protected]> files: A Misc/NEWS.d/next/Core_and_Builtins/2026-03-21-08-48-25.gh-issue-146245.cqM3_4.rst M 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 index 00000000000000..f52eaa0d6c7277 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2026-03-21-08-48-25.gh-issue-146245.cqM3_4.rst @@ -0,0 +1 @@ +Fixed reference leaks in :mod:`socket` when audit hooks raise exceptions in :func:`socket.getaddrinfo` and :meth:`!socket.sendto`. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 37d6209a21aefe..4ea2de9f408979 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -4582,6 +4582,7 @@ sock_sendto(PySocketSockObject *s, PyObject *args) } if (PySys_Audit("socket.sendto", "OO", s, addro) < 0) { + PyBuffer_Release(&pbuf); return NULL; } @@ -6801,7 +6802,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)); _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
