From 2db2114fe2ddad2723c4242f0404948cd7a9f0b8 Mon Sep 17 00:00:00 2001 From: Chad Loder Date: Sat, 12 Mar 2005 22:17:36 +0000 Subject: Do not leak mem or fd in error paths. From Andrey Matveev (thanks!). OK niallo@ deraadt@: "stop polishing turds and commit already" --- usr.sbin/popa3d/standalone.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/usr.sbin/popa3d/standalone.c b/usr.sbin/popa3d/standalone.c index 0e9d6ba2d1e..43e9d82353e 100644 --- a/usr.sbin/popa3d/standalone.c +++ b/usr.sbin/popa3d/standalone.c @@ -1,4 +1,4 @@ -/* $OpenBSD: standalone.c,v 1.8 2004/07/20 17:07:34 millert Exp $ */ +/* $OpenBSD: standalone.c,v 1.9 2005/03/12 22:17:35 cloder Exp $ */ /* * Standalone POP server: accepts connections, checks the anti-flood limits, @@ -136,8 +136,10 @@ int main(void) i++; pfds = calloc(i, sizeof(pfds[0])); - if (!pfds) + if (!pfds) { + freeaddrinfo(res0); return log_error("malloc"); + } i = 0; for (res = res0; res; res = res->ai_next) { @@ -247,7 +249,8 @@ handle(int sock) hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST); if (error) { syslog(SYSLOG_PRI_HI, - "%s: invalid IP address", hbuf); + "could not get host address"); + close(new); return -1; } -- cgit v1.2.3