about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-28 08:15:39 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-28 08:15:39 +0000
commit7cafc466deb29417053b6927c36e4ea29108c029 (patch)
treeb9b37fdbf3cfe4b7b86807a70eb8b5bf34e46518 /lib
parentf5e6b462646f5a20dd0e5f6c4befaa7b72d1e1ff (diff)
downloadklee-7cafc466deb29417053b6927c36e4ea29108c029.tar.gz
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
Diffstat (limited to 'lib')
-rw-r--r--lib/Core/Common.cpp32
1 files changed, 14 insertions, 18 deletions
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);
 }