Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-146245: Fix reference and buffer leaks via audit hook in socket mo…
…dule (GH-146248)

(cherry picked from commit c30fae4)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
  • Loading branch information
aisk authored and miss-islington committed Mar 22, 2026
commit c64d830b28bae55ba607f381c036f70e8455759c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed reference leaks in :mod:`socket` when audit hooks raise exceptions in :func:`socket.getaddrinfo` and :meth:`!socket.sendto`.
3 changes: 2 additions & 1 deletion Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4582,6 +4582,7 @@ sock_sendto(PySocketSockObject *s, PyObject *args)
}

if (PySys_Audit("socket.sendto", "OO", s, addro) < 0) {
PyBuffer_Release(&pbuf);
return NULL;
}

Expand Down Expand Up @@ -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));
Expand Down
Loading