Recently Written · git

sacc

Mirror of git://bitreich.org/sacc, the sacc gopher client from bitreich.org.

git clone https://github.com/equwal/sacc

Log | Files | Refs


commit 10ed3e55246b65f39aa19f3c63bb0241c62d4f6c
Hiltjo Posthuma <hiltjo@codemadness.org>
2018-12-25 19:32:54 +0100

freeaddrinfo can leak if a connection fails in connectto()

 sacc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sacc.c b/sacc.c
index a07f23b..7a68bb9 100644
--- a/sacc.c
+++ b/sacc.c
@@ -478,6 +478,9 @@ connectto(const char *host, const char *port)
 		}
 		break;
 	}
+
+	freeaddrinfo(addrs);
+
 	if (sock < 0) {
 		diag("Can't open socket: %s", strerror(errno));
 		return -1;
@@ -488,8 +491,6 @@ connectto(const char *host, const char *port)
 		return -1;
 	}
 
-	freeaddrinfo(addrs);
-
 	return sock;
 }