net: fix leaking sockets in dial_tcp if connect errors

This commit is contained in:
Laytan Laats
2024-10-08 21:01:57 +02:00
parent b839d06ac8
commit d8af35f01e
4 changed files with 8 additions and 7 deletions
+2 -2
View File
@@ -80,8 +80,8 @@ _dial_tcp_from_endpoint :: proc(endpoint: Endpoint, options := default_tcp_optio
sockaddr := _endpoint_to_sockaddr(endpoint)
res := win.connect(win.SOCKET(socket), &sockaddr, size_of(sockaddr))
if res < 0 {
err = Dial_Error(win.WSAGetLastError())
return
close(socket)
return {}, Dial_Error(win.WSAGetLastError())
}
if options.no_delay {