From: Joel Rosdahl Date: Sun, 9 May 2010 18:00:09 +0000 (+0200) Subject: Handle va_list correctly in fatal() when also writing to log file X-Git-Tag: v3.0pre1~16 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=66f175d54d03d4b380698a8d896fa9c942001e2b;p=thirdparty%2Fccache.git Handle va_list correctly in fatal() when also writing to log file --- diff --git a/util.c b/util.c index 4ac710905..ccbbc5a6f 100644 --- a/util.c +++ b/util.c @@ -66,25 +66,24 @@ void fatal(const char *format, ...) { va_list ap; extern char *cache_logfile; + char msg[1000]; va_start(ap, format); + vsnprintf(msg, sizeof(msg), format, ap); + va_end(ap); if (cache_logfile) { if (!logfile) { logfile = fopen(cache_logfile, "a"); } if (logfile) { - fprintf(logfile, "[%-5d] FATAL: ", getpid()); - vfprintf(logfile, format, ap); + fprintf(logfile, "[%-5d] FATAL: %s", getpid(), msg); fflush(logfile); } } - fprintf(stderr, "ccache: FATAL: "); - vfprintf(stderr, format, ap); - fprintf(stderr, "\n"); + fprintf(stderr, "ccache: FATAL: %s\n", msg); - va_end(ap); exit(1); }