Skip to content

Commit 69a37be

Browse files
miss-islingtonaisk
andauthored
[3.14] gh-146245: Fix reference and buffer leaks via audit hook in socket module (GH-146248) (GH-146274)
(cherry picked from commit c30fae4) Co-authored-by: AN Long <aisk@users.noreply.github.com>
1 parent 7965133 commit 69a37be

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed reference leaks in :mod:`socket` when audit hooks raise exceptions in :func:`socket.getaddrinfo` and :meth:`!socket.sendto`.

Modules/socketmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4795,6 +4795,7 @@ sock_sendto(PyObject *self, PyObject *args)
47954795
}
47964796

47974797
if (PySys_Audit("socket.sendto", "OO", s, addro) < 0) {
4798+
PyBuffer_Release(&pbuf);
47984799
return NULL;
47994800
}
48004801

@@ -6965,7 +6966,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
69656966

69666967
if (PySys_Audit("socket.getaddrinfo", "OOiii",
69676968
hobj, pobj, family, socktype, protocol) < 0) {
6968-
return NULL;
6969+
goto err;
69696970
}
69706971

69716972
memset(&hints, 0, sizeof(hints));

0 commit comments

Comments
 (0)