reinitialize print arguments
authorAndreas Steffen <andreas@strongswan.org>
Mon, 17 Aug 2009 08:54:34 +0000 (10:54 +0200)
committerAndreas Steffen <andreas@strongswan.org>
Mon, 17 Aug 2009 08:54:34 +0000 (10:54 +0200)
src/openac/openac.c
src/scepclient/loglite.c

index 408da7f..f61a946 100755 (executable)
@@ -218,15 +218,16 @@ static void openac_dbg(int level, char *fmt, ...)
        
        if (level <= debug_level)
        {
-               va_start(args, fmt);
-
                if (!stderr_quiet)
                {
+                       va_start(args, fmt);
                        vfprintf(stderr, fmt, args);
                        fprintf(stderr, "\n");
+                       va_end(args);
                }
 
                /* write in memory buffer first */
+               va_start(args, fmt);
                vsnprintf(buffer, sizeof(buffer), fmt, args);
                va_end(args);
 
index b14e72e..87041f1 100644 (file)
@@ -68,21 +68,23 @@ static void scepclient_dbg(int level, char *fmt, ...)
 
        if (level <= debug_level)
        {
-               va_start(args, fmt);
-
                if (log_to_stderr)
                {
                        if (level > 1)
                        {
                                fprintf(stderr, "| ");
                        }
+                       va_start(args, fmt);
                        vfprintf(stderr, fmt, args);
+                       va_end(args);
                        fprintf(stderr, "\n");
                }
                if (log_to_syslog)
                {
                        /* write in memory buffer first */
+                       va_start(args, fmt);
                        vsnprintf(buffer, sizeof(buffer), fmt, args);
+                       va_end(args);
 
                        /* do a syslog with every line */
                        while (current)
@@ -96,7 +98,6 @@ static void scepclient_dbg(int level, char *fmt, ...)
                                current = next;
                        }
                }
-               va_end(args);
        }
 }