Fix va_list not being reset between 2 uses
authorChristophe Varoqui <christophe.varoqui@opensvc.com>
Fri, 30 Sep 2016 16:16:38 +0000 (18:16 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Fri, 30 Sep 2016 16:16:38 +0000 (18:16 +0200)
Causing segfault in the console logging when the daemon is run
in foreground

debug.c

diff --git a/debug.c b/debug.c
index 7b7a42e..091fa44 100644 (file)
--- a/debug.c
+++ b/debug.c
 void dlog (int sink, int prio, const char * fmt, ...)
 {
        va_list ap;
+       va_list app;
 
        va_start(ap, fmt);
 
        if (prio > log_threshold)
                return;
 
-       if (sink & LOGSINK_SYSLOG)
-               vsyslog(prio, fmt, ap);
-
-       if (sink & LOGSINK_CONSOLE)
+       if (sink & LOGSINK_SYSLOG) {
+               *app = *ap;
+               vsyslog(prio, fmt, app);
+       }
+       if (sink & LOGSINK_CONSOLE) {
+               *app = *ap;
                vfprintf(stdout, fmt, ap);
-
+       }
        va_end(ap);
 }