Skip to content

Commit 2f1e341

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

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
@@ -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)