Fix small leak on failed realloc in _g_locale_get_charset_aliases
authorPascal Terjan <pterjan@linuxfr.org>
Thu, 26 Oct 2006 21:09:04 +0000 (21:09 +0000)
committerPascal Terjan <pterjan@src.gnome.org>
Thu, 26 Oct 2006 21:09:04 +0000 (21:09 +0000)
2006-10-26  Pascal Terjan  <pterjan@linuxfr.org>

* glib/libcharset/localcharset.c: Fix small leak on failed
realloc in _g_locale_get_charset_aliases (#338582)

ChangeLog
glib/libcharset/localcharset.c

index 72c6813..c81087a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-26  Pascal Terjan  <pterjan@linuxfr.org>
+
+       * glib/libcharset/localcharset.c: Fix small leak on failed
+       realloc in _g_locale_get_charset_aliases (#338582)
+
 2006-10-16  Behdad Esfahbod  <behdad@gnome.org>
 
        * glib/gnulib/Makefile.am: Add $(GLIB_DEBUG_FLAGS).  (#362543,
index 2b799b8..eaa997e 100644 (file)
@@ -183,8 +183,12 @@ _g_locale_get_charset_aliases (void)
                }
              else
                {
+                 char * p = res_ptr;
                  res_size += l1 + 1 + l2 + 1;
                  res_ptr = (char *) realloc (res_ptr, res_size + 1);
+                 if (res_ptr == NULL) {
+                   free(p);
+                 }
                }
              if (res_ptr == NULL)
                {