Skip to content

Commit c64d830

Browse files
aiskmiss-islington
authored andcommitted
pythongh-146245: Fix reference and buffer leaks via audit hook in socket module (pythonGH-146248)
(cherry picked from commit c30fae4) Co-authored-by: AN Long <aisk@users.noreply.github.com>
1 parent fab8267 commit c64d830

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

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
@@ -4582,6 +4582,7 @@ sock_sendto(PySocketSockObject *s, PyObject *args)
45824582
}
45834583

45844584
if (PySys_Audit("socket.sendto", "OO", s, addro) < 0) {
4585+
PyBuffer_Release(&pbuf);
45854586
return NULL;
45864587
}
45874588

@@ -6801,7 +6802,7 @@ socket_getaddrinfo(PyObject *self, PyObject *args, PyObject* kwargs)
68016802

68026803
if (PySys_Audit("socket.getaddrinfo", "OOiii",
68036804
hobj, pobj, family, socktype, protocol) < 0) {
6804-
return NULL;
6805+
goto err;
68056806
}
68066807

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

0 commit comments

Comments
 (0)