Skip to content

Commit c30fae4

Browse files
authored
gh-146245: Fix reference and buffer leaks via audit hook in socket module (GH-146248)
1 parent f0aeabc commit c30fae4

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
@@ -4808,6 +4808,7 @@ sock_sendto(PyObject *self, PyObject *args)
48084808
}
48094809

48104810
if (PySys_Audit("socket.sendto", "OO", s, addro) < 0) {
4811+
PyBuffer_Release(&pbuf);
48114812
return NULL;
48124813
}
48134814

@@ -6982,7 +6983,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
69826983

69836984
if (PySys_Audit("socket.getaddrinfo", "OOiii",
69846985
hobj, pobj, family, socktype, protocol) < 0) {
6985-
return NULL;
6986+
goto err;
69866987
}
69876988

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

0 commit comments

Comments
 (0)