Copy a va_list when using it multiple times. Reported by Wim Lewis.
authorMatthias Clasen <matthiasc@src.gnome.org>
Sun, 29 Mar 2009 19:08:57 +0000 (19:08 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sun, 29 Mar 2009 19:08:57 +0000 (19:08 +0000)
        * glib/gmessages.c (g_logv): Copy a va_list when using it
        multiple times. Reported by Wim Lewis.

svn path=/trunk/; revision=8021

ChangeLog
glib/gmessages.c

index 28abae5..cf61d68 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-03-29  Matthias Clasen  <mclasen@redhat.com>
+
+       Bug 577137 – g_logv() will crash if given format args and multiple
+       log levels
+
+       * glib/gmessages.c (g_logv): Copy a va_list when using it
+       multiple times. Reported by Wim Lewis.
+
 2009-03-16  Alexander Larsson  <alexl@redhat.com>
 
        Bug 575555 – Use fsync() when replacing files to avoid data loss on crash
index 7b90a02..e080ad6 100644 (file)
@@ -462,14 +462,23 @@ g_logv (const gchar   *log_domain,
               * in an out-of-memory situation
               */
              gchar buffer[1025];
-             gint size;
-             size = _g_vsnprintf (buffer, 1024, format, args1);
+              gsize size;
+              va_list args2;
+
+              G_VA_COPY (args2, args1);
+             size = _g_vsnprintf (buffer, 1024, format, args2);
+              va_end (args2);
 
              log_func (log_domain, test_level, buffer, data);
            }
          else
            {
-             gchar *msg = g_strdup_vprintf (format, args1);
+             gchar *msg;
+              va_list args2;
+
+              G_VA_COPY (args2, args1);
+              msg = g_strdup_vprintf (format, args2);
+              va_end (args2);
 
              log_func (log_domain, test_level, msg, data);