Fix #147651, reported by Oliver Guntermann:
authorMatthias Clasen <mclasen@redhat.com>
Wed, 21 Jul 2004 17:51:28 +0000 (17:51 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 21 Jul 2004 17:51:28 +0000 (17:51 +0000)
2004-07-21  Matthias Clasen  <mclasen@redhat.com>

Fix #147651, reported by Oliver Guntermann:

* glib/gprintfint.h (_g_vasprintf): Don't wrap vasprintf(),
_g_gnulib_vasprintf() in a macro, since they behave
differently wrt. to memory allocation.

* glib/gprintf.c (g_vasprintf): Instead, differentiate
here between the three cases: system vasprintf(),
_g_gnulib_vasprintf(), no vasprintf().

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gprintf.c
glib/gprintfint.h

index 6fd8ef7..bf22bb5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-07-21  Matthias Clasen  <mclasen@redhat.com>
+
+       Fix #147651, reported by Oliver Guntermann:
+
+       * glib/gprintfint.h (_g_vasprintf): Don't wrap vasprintf(),
+       _g_gnulib_vasprintf() in a macro, since they behave 
+       differently wrt. to memory allocation.
+
+       * glib/gprintf.c (g_vasprintf): Instead, differentiate 
+       here between the three cases: system vasprintf(), 
+       _g_gnulib_vasprintf(), no vasprintf().  
+
 2004-07-20  Crispin Flowerday  <gnome@flowerday.cx>
 
        * NEWS: Fix a typo in my name
index 6fd8ef7..bf22bb5 100644 (file)
@@ -1,3 +1,15 @@
+2004-07-21  Matthias Clasen  <mclasen@redhat.com>
+
+       Fix #147651, reported by Oliver Guntermann:
+
+       * glib/gprintfint.h (_g_vasprintf): Don't wrap vasprintf(),
+       _g_gnulib_vasprintf() in a macro, since they behave 
+       differently wrt. to memory allocation.
+
+       * glib/gprintf.c (g_vasprintf): Instead, differentiate 
+       here between the three cases: system vasprintf(), 
+       _g_gnulib_vasprintf(), no vasprintf().  
+
 2004-07-20  Crispin Flowerday  <gnome@flowerday.cx>
 
        * NEWS: Fix a typo in my name
index 6fd8ef7..bf22bb5 100644 (file)
@@ -1,3 +1,15 @@
+2004-07-21  Matthias Clasen  <mclasen@redhat.com>
+
+       Fix #147651, reported by Oliver Guntermann:
+
+       * glib/gprintfint.h (_g_vasprintf): Don't wrap vasprintf(),
+       _g_gnulib_vasprintf() in a macro, since they behave 
+       differently wrt. to memory allocation.
+
+       * glib/gprintf.c (g_vasprintf): Instead, differentiate 
+       here between the three cases: system vasprintf(), 
+       _g_gnulib_vasprintf(), no vasprintf().  
+
 2004-07-20  Crispin Flowerday  <gnome@flowerday.cx>
 
        * NEWS: Fix a typo in my name
index 6fd8ef7..bf22bb5 100644 (file)
@@ -1,3 +1,15 @@
+2004-07-21  Matthias Clasen  <mclasen@redhat.com>
+
+       Fix #147651, reported by Oliver Guntermann:
+
+       * glib/gprintfint.h (_g_vasprintf): Don't wrap vasprintf(),
+       _g_gnulib_vasprintf() in a macro, since they behave 
+       differently wrt. to memory allocation.
+
+       * glib/gprintf.c (g_vasprintf): Instead, differentiate 
+       here between the three cases: system vasprintf(), 
+       _g_gnulib_vasprintf(), no vasprintf().  
+
 2004-07-20  Crispin Flowerday  <gnome@flowerday.cx>
 
        * NEWS: Fix a typo in my name
index 6fd8ef7..bf22bb5 100644 (file)
@@ -1,3 +1,15 @@
+2004-07-21  Matthias Clasen  <mclasen@redhat.com>
+
+       Fix #147651, reported by Oliver Guntermann:
+
+       * glib/gprintfint.h (_g_vasprintf): Don't wrap vasprintf(),
+       _g_gnulib_vasprintf() in a macro, since they behave 
+       differently wrt. to memory allocation.
+
+       * glib/gprintf.c (g_vasprintf): Instead, differentiate 
+       here between the three cases: system vasprintf(), 
+       _g_gnulib_vasprintf(), no vasprintf().  
+
 2004-07-20  Crispin Flowerday  <gnome@flowerday.cx>
 
        * NEWS: Fix a typo in my name
index 9b511ea..522a7f6 100644 (file)
@@ -300,17 +300,27 @@ g_vasprintf (gchar      **string,
   gint len;
   g_return_val_if_fail (string != NULL, -1);
 
-#ifdef _g_vasprintf
-  len = _g_vasprintf (string, format, args);
+#if !defined(HAVE_GOOD_PRINTF)
+
+  len = _g_gnulib_vasprintf (string, format, args);
+  if (len < 0)
+    *string = NULL;
+
+#elif defined (HAVE_VASPRINTF)
+
+  len = vasprintf (string, format, args);
   if (len < 0)
     *string = NULL;
   else if (!g_mem_is_system_malloc ()) 
     {
+      /* vasprintf returns malloc-allocated memory */
       gchar *string1 = g_strndup (*string, len);
       free (*string);
       *string = string1;
     }
+
 #else
+
   {
     va_list args2;
 
@@ -328,3 +338,4 @@ g_vasprintf (gchar      **string,
 
 
 
+
index 2195e6f..0c975a1 100644 (file)
 #define _g_vsprintf  vsprintf
 #define _g_vsnprintf vsnprintf
 
-#ifdef HAVE_VASPRINTF
-#define _g_vasprintf vasprintf
-#endif
-
 #else
 
 #include "gnulib/printf.h"
@@ -57,8 +53,6 @@
 #define _g_vsprintf  _g_gnulib_vsprintf
 #define _g_vsnprintf _g_gnulib_vsnprintf
 
-#define _g_vasprintf _g_gnulib_vasprintf
-
 #endif
 
 #endif /* __G_PRINTF_H__ */