diff options
author | Jo-Philipp Wich <jo@mein.io> | 2024-05-13 09:54:24 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2024-05-13 09:54:24 +0200 |
commit | 8cf816d615fd063ba1463f64b6428e59a91e9651 (patch) | |
tree | 60f29be004bf671dd7578804c66e4912f78b5a7f /lib | |
parent | 0d823e702bfe5f2bb5be694030a98afedf34aa6b (diff) |
socket: fix potential memory leak in connect()
If a non-string value which cannot be interpreted as socket address
structure is passed to connect(), the function will leak the internal
address vector when returning the error.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lib')
-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); |