summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2024-05-14 08:53:14 +0200
committerGitHub <noreply@github.com>2024-05-14 08:53:14 +0200
commitecc6947ddeb6d6543b78c0423f3121df299cbd1a (patch)
tree60f29be004bf671dd7578804c66e4912f78b5a7f
parent0d823e702bfe5f2bb5be694030a98afedf34aa6b (diff)
parent8cf816d615fd063ba1463f64b6428e59a91e9651 (diff)
Merge pull request #200 from jow-/socket-leak-fix
socket: fix potential memory leak in connect()
-rw-r--r--lib/socket.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/socket.c b/lib/socket.c
index d0bd152..159f81c 100644
--- a/lib/socket.c
+++ b/lib/socket.c
@@ -2228,8 +2228,11 @@ uc_socket_connect(uc_vm_t *vm, size_t nargs)
uc_vector_grow(&addresses);
ap = &addresses.entries[addresses.count++];
- if (!uv_to_sockaddr(host, &ap->ss, &ap->ai.ai_addrlen))
+ if (!uv_to_sockaddr(host, &ap->ss, &ap->ai.ai_addrlen)) {
+ free(ai_hints);
+ uc_vector_clear(&addresses);
return NULL;
+ }
if (serv) {
uint64_t port = ucv_to_unsigned(serv);