Skip to content

Commit

Permalink
close properly if connect fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosentino11 authored Jun 6, 2024
1 parent 68fdf02 commit 5aed8b6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5aed8b6

Please sign in to comment.