ref: 961ec70f7759ad28fa7c0bd8493ceb2b2aa4ec99
parent: d93d385b79eea9111edc7a4822fbcfff36d537ae
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Nov 18 12:39:41 EST 2021
9gc: fix socket leak
--- a/9gc.c
+++ b/9gc.c
@@ -146,11 +146,10 @@
for (a = r; a != NULL; a = a->ai_next) {
if ((f = socket(a->ai_family, a->ai_socktype, a->ai_protocol)) < 0)
continue;
- if (connect(f, a->ai_addr, a->ai_addrlen) != 0) {
- close(f);
- f = -1;
- continue;
- }
+ if (connect(f, a->ai_addr, a->ai_addrlen) == 0)
+ break;
+ close(f);
+ f = -1;
}
freeaddrinfo(r);