From f85b221da6b165f966a6048eb4d1c059f7b1be4b Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Mon, 17 Dec 2012 13:02:41 +1030 Subject: [PATCH] common: fix varargs use in log{,v}print Signed-off-by: Kevin Shanahan --- common/log.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/common/log.c b/common/log.c index 727884cb..27047f3e 100644 --- a/common/log.c +++ b/common/log.c @@ -21,9 +21,11 @@ * common/log.c */ +#include +#include + #include #include -#include static FILE *logfile; static qboolean log_ok; @@ -48,20 +50,27 @@ logprint(const char *fmt, ...) { va_list args; - va_start(args, fmt); - vprintf(fmt, args); if (log_ok) { + va_start(args, fmt); vfprintf(logfile, fmt, args); + va_end(args); fflush(logfile); } + va_start(args, fmt); + vprintf(fmt, args); + va_end(args); } void logvprint(const char *fmt, va_list args) { - vprintf(fmt, args); + va_list log_args; + if (log_ok) { - vfprintf(logfile, fmt, args); + va_copy(log_args, args); + vfprintf(logfile, fmt, log_args); + va_end(log_args); fflush(logfile); } + vprintf(fmt, args); }