Copy a va_list when using it multiple times. Reported by Wim Lewis.

* glib/gmessages.c (g_logv): Copy a va_list when using it
        multiple times. Reported by Wim Lewis.


svn path=/trunk/; revision=8021
This commit is contained in:
Matthias Clasen 2009-03-29 19:08:57 +00:00
parent dabbea65c6
commit a6ebda3d69
2 changed files with 20 additions and 3 deletions

View File

@ -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

View 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);