diff --git a/ChangeLog b/ChangeLog index 28abae5cd..cf61d68d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-03-29 Matthias Clasen + + 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 Bug 575555 – Use fsync() when replacing files to avoid data loss on crash diff --git a/glib/gmessages.c b/glib/gmessages.c index 7b90a0215..e080ad6db 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -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);