summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2016-04-29 10:48:05 +0200
committerTobias Klauser <tklauser@distanz.ch>2016-04-29 10:48:05 +0200
commitc7f21bebbeadf36f71251b6b0c62f2d93b308a5c (patch)
tree4ee71b5d482861c384bfab714a17858ea218de6a
parent668d66c4e1f79081d1096c7cf63e807637b88237 (diff)
iface: Fix memory leak in error case
If add from leaking in case the address was (unexpectedly) not found. This addresses CID 99695 discovered by the Coverity scanner. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--iface.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/iface.c b/iface.c
index b069532..4bc9b5e 100644
--- a/iface.c
+++ b/iface.c
@@ -145,10 +145,13 @@ static void iface_record_addr_del(struct iface_record *rec, struct sockaddr_stor
rec->size--;
} else {
char as[NI_MAXHOST];
+
if (getnameinfo((struct sockaddr *)addr, sizeof(*addr),
as, sizeof(as), NULL, 0, NI_NUMERICHOST))
strncpy(as, "<unknown>", sizeof(as) - 1);
log_err("Address %s to delete not found in records\n", as);
+
+ free(addrs);
}
} else if (rec->size == 1) {
free(rec->addrs);