aboutsummaryrefslogtreecommitdiff
path: root/core/net/socket_linux.odin
diff options
context:
space:
mode:
authorLaytan Laats <laytanlaats@hotmail.com>2024-10-08 21:01:57 +0200
committerLaytan Laats <laytanlaats@hotmail.com>2024-10-08 21:01:57 +0200
commitd8af35f01e71ba1c711cd6d6c5fe0a43116c29f0 (patch)
treefe2cfa069697063d9beed65b472c3edc16d3c55b /core/net/socket_linux.odin
parentb839d06ac84f193252d5f3e5e76c432f623211bd (diff)
net: fix leaking sockets in dial_tcp if connect errors
Diffstat (limited to 'core/net/socket_linux.odin')
-rw-r--r--core/net/socket_linux.odin3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/net/socket_linux.odin b/core/net/socket_linux.odin
index a3853874a..be189f5c1 100644
--- a/core/net/socket_linux.odin
+++ b/core/net/socket_linux.odin
@@ -147,7 +147,8 @@ _dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := default_tcp_optio
addr := _unwrap_os_addr(endpoint)
errno = linux.connect(linux.Fd(os_sock), &addr)
if errno != .NONE {
- return cast(TCP_Socket) os_sock, Dial_Error(errno)
+ close(cast(TCP_Socket) os_sock)
+ return {}, Dial_Error(errno)
}
// NOTE(tetra): Not vital to succeed; error ignored
no_delay: b32 = cast(b32) options.no_delay