From ae8e632a4610faf2d5708a553e9dca40f708c8eb Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Mon, 16 May 2016 08:56:56 +0200 Subject: [PATCH] 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. --- src/log.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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); } -- 2.39.5