[Libpst-commits] r65 - trunk

Joseph Nahmias jello at alioth.debian.org
Wed Dec 13 20:34:44 CET 2006


Author: jello
Date: 2006-12-13 20:34:43 +0100 (Wed, 13 Dec 2006)
New Revision: 65

Modified:
   trunk/debug.c
Log:
_debug_msg_text(): make sure to reset ap with va_end() and va_start() as needed.
Thanks to Chris Hall for the patch!


Index: trunk/debug.c
===================================================================
--- trunk/debug.c	(revision 64)
+++ trunk/debug.c	(revision 65)
@@ -159,13 +159,16 @@ void _debug_msg_text(char* fmt, ...) {
 #else
   f = vsnprintf(x, 1, fmt, ap);
 #endif
+  va_end(ap);  // must be called after vsnprintf()
 
   if (f > 0 && f < MAX_MESSAGE_SIZE) {
     info_ptr->text = (char*) xmalloc(f+1);
+    va_start(ap, fmt);
     if ((g = vsnprintf(info_ptr->text, f, fmt, ap)) == -1) {
       fprintf(stderr, "_debug_msg: Dieing! vsnprintf returned -1 for format \"%s\"\n", fmt);
       exit(-2);
     }
+    va_end(ap);
     info_ptr->text[g] = '\0';
     if (f != g) {
       fprintf(stderr, "_debug_msg: f != g\n");
@@ -175,7 +178,9 @@ void _debug_msg_text(char* fmt, ...) {
     temp = info_ptr;
     _debug_write(); // dump the current messages
     info_ptr = temp;
+    va_start(ap, fmt);
     _debug_write_msg(info_ptr, fmt, &ap, f);
+    va_end(ap);
     free(info_ptr->function);
     free(info_ptr->file);
     free(info_ptr);
@@ -185,7 +190,6 @@ void _debug_msg_text(char* fmt, ...) {
     fprintf(stderr, "_debug_msg: error getting requested size of debug message\n");
     info_ptr->text = "ERROR Saving\n";
   }
-  va_end(ap);
 
   if (item_head == NULL)
     item_head = info_ptr;



More information about the Libpst-commits mailing list