From: Vincent Bernat Date: Mon, 16 May 2016 06:56:56 +0000 (+0200) Subject: log: make a copy of va when logging to both stderr and syslog X-Git-Tag: 0.9.3~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ae8e632a4610faf2d5708a553e9dca40f708c8eb;p=thirdparty%2Flldpd.git log: make a copy of va when logging to both stderr and syslog On common platform, the copy is cheap. In case it isn't we note that the copy doesn't happen if using a log handler and syslog cannot be enabled with debug messages. --- diff --git a/src/log.c b/src/log.c index 8c85d5a1..6596950e 100644 --- a/src/log.c +++ b/src/log.c @@ -149,6 +149,12 @@ vlog(int pri, const char *token, const char *fmt, va_list ap) return; } + /* Log to syslog if requested */ + if (use_syslog) { + va_list ap2; + va_copy(ap2, ap); + vsyslog(pri, fmt, ap2); + va_end(ap2); } /* Log to standard error in all cases */ @@ -167,10 +173,6 @@ vlog(int pri, const char *token, const char *fmt, va_list ap) free(nfmt); } fflush(stderr); - - /* Log to syslog if requested */ - if (use_syslog) - vsyslog(pri, fmt, ap); }