From 9a93a32b717256d326877e7772ddb7e9ead8231a Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Tue, 30 Dec 2003 18:47:01 +0000 Subject: missing free()s; From: Patrick Latifi --- usr.sbin/bgpd/log.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bgpd/log.c b/usr.sbin/bgpd/log.c index 616fe6174fb..ef363fa48a6 100644 --- a/usr.sbin/bgpd/log.c +++ b/usr.sbin/bgpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.12 2003/12/30 13:03:27 henning Exp $ */ +/* $OpenBSD: log.c,v 1.13 2003/12/30 18:47:00 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer @@ -178,6 +178,7 @@ log_peer_err(const struct peer *peer, const char *emsg, ...) vlog(LOG_CRIT, nfmt, ap); va_end(ap); free(p); + free(nfmt); } void @@ -193,6 +194,7 @@ log_peer_errx(const struct peer *peer, const char *emsg, ...) vlog(LOG_CRIT, nfmt, ap); va_end(ap); free(p); + free(nfmt); } void @@ -202,20 +204,21 @@ log_err(const char *emsg, ...) va_list ap; /* best effort to even work in out of memory situations */ - - va_start(ap, emsg); - if (emsg == NULL) logit(LOG_CRIT, "%s", strerror(errno)); else { + va_start(ap, emsg); + if (asprintf(&nfmt, "%s: %s", emsg, strerror(errno)) == -1) { /* we tried it... */ vlog(LOG_CRIT, emsg, ap); logit(LOG_CRIT, "%s", strerror(errno)); - } else + } else { vlog(LOG_CRIT, nfmt, ap); + free(nfmt); + } + va_end(ap); } - va_end(ap); } void -- cgit v1.2.3