[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[master] It's necessary to give each vfprintf invocation a frash va_list (#568235)



Commit 3fb12e4eafebfa3885c25b9ab93e9c35f6847425 changed the way variable
argument list is handled in log.c this causes SIGSEGV on x86_64.

I should see 'man vfprintf' the next time.
---
 loader/log.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/loader/log.c b/loader/log.c
index 5ed3c6a..7824d92 100644
--- a/loader/log.c
+++ b/loader/log.c
@@ -97,14 +97,17 @@ static void printLogHeader(int level, FILE *outfile) {
 
 void logMessageV(int level, const char * s, va_list ap) {
     va_list apc;
-    va_copy(apc, ap);
     /* Log everything into syslog */
+    va_copy(apc, ap);
     vsyslog(mapLogLevel(level), s, apc);
+    va_end(apc);
 
     /* Only log to the screen things that are above the minimum level. */
     if (tty_logfile && level >= minLevel) {
         printLogHeader(level, tty_logfile);
+        va_copy(apc, ap);
         vfprintf(tty_logfile, s, apc);
+        va_end(apc);
         fprintf(tty_logfile, "\n");
         fflush(tty_logfile);
     }
@@ -112,12 +115,12 @@ void logMessageV(int level, const char * s, va_list ap) {
     /* But log everything to the file. */
     if (file_logfile) {
         printLogHeader(level, file_logfile);
+        va_copy(apc, ap);
         vfprintf(file_logfile, s, apc);
+        va_end(apc);
         fprintf(file_logfile, "\n");
         fflush(file_logfile);
     }
-
-    va_end(apc);
 }
 
 void logMessage(int level, const char * s, ...) {
-- 
1.6.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]