From 7cafc466deb29417053b6927c36e4ea29108c029 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 28 Jul 2009 08:15:39 +0000 Subject: KLEE64: Fix some totally bogus printing code, which was reusing a va_list without va_copy()ing it. git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@77307 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Core/Common.cpp | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/Core/Common.cpp b/lib/Core/Common.cpp index 479c4465..44cdc9f0 100644 --- a/lib/Core/Common.cpp +++ b/lib/Core/Common.cpp @@ -22,6 +22,14 @@ using namespace klee; FILE* klee::klee_warning_file = NULL; FILE* klee::klee_message_file = NULL; +static void klee_vfmessage(FILE *fp, const char *pfx, const char *msg, + va_list ap) { + fprintf(fp, "KLEE: "); + if (pfx) fprintf(fp, "%s: ", pfx); + vfprintf(fp, msg, ap); + fprintf(fp, "\n"); + fflush(fp); +} /* Prints a message/warning. @@ -31,27 +39,15 @@ FILE* klee::klee_message_file = NULL; Iff onlyToFile is false, the message is also printed on stderr. */ -static void klee_vmessage(const char *pfx, bool onlyToFile, const char *msg, va_list ap) { - FILE *f = stderr; +static void klee_vmessage(const char *pfx, bool onlyToFile, const char *msg, + va_list ap) { if (!onlyToFile) { - fprintf(f, "KLEE: "); - if (pfx) fprintf(f, "%s: ", pfx); - vfprintf(f, msg, ap); - fprintf(f, "\n"); - fflush(f); + va_list ap2; + va_copy(ap2, ap); + klee_vfmessage(stderr, pfx, msg, ap2); } - if (pfx == NULL) - f = klee_message_file; - else f = klee_warning_file; - - if (f) { - fprintf(f, "KLEE: "); - if (pfx) fprintf(f, "%s: ", pfx); - vfprintf(f, msg, ap); - fprintf(f, "\n"); - fflush(f); - } + klee_vfmessage(pfx ? klee_message_file : klee_warning_file, pfx, msg, ap); } -- cgit 1.4.1