diff options
author | Jo-Philipp Wich <jo@mein.io> | 2024-05-14 08:53:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-14 08:53:14 +0200 |
commit | ecc6947ddeb6d6543b78c0423f3121df299cbd1a (patch) | |
tree | 60f29be004bf671dd7578804c66e4912f78b5a7f | |
parent | 0d823e702bfe5f2bb5be694030a98afedf34aa6b (diff) | |
parent | 8cf816d615fd063ba1463f64b6428e59a91e9651 (diff) |
Merge pull request #200 from jow-/socket-leak-fix
socket: fix potential memory leak in connect()
-rw-r--r-- | lib/socket.c | 5 |
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); |