From 5aed8b62dafce28fd524e67f661a1c6427808772 Mon Sep 17 00:00:00 2001 From: Joseph Cosentino Date: Thu, 6 Jun 2024 09:51:22 -0700 Subject: [PATCH] close properly if connect fails --- src/Network.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Network.cpp b/src/Network.cpp index e4f92e4..157d1df 100644 --- a/src/Network.cpp +++ b/src/Network.cpp @@ -83,10 +83,13 @@ bool Network::netConnect() { if (connect(mSock, addr->ai_addr, addr->ai_addrlen) < 0) { std::cerr << "unable to connect to host: " << strerror(errno) << "\n"; - break; + freeaddrinfo(addrs); + netClose(); + return false; } } + // socket failed for all addrs if (mSock < 0) { freeaddrinfo(addrs); netClose();