[glib] Plug a mem leak in g_environ_unsetenv



commit 2f4b46e3783b04cddcb2622a57b2a8e692cff68a
Author: Christian Persch <chpe gnome org>
Date:   Sun Feb 5 16:00:31 2012 +0100

    Plug a mem leak in g_environ_unsetenv
    
    ==9458== 10 bytes in 1 blocks are definitely lost in loss record 16 of 39
    ==9458==    at 0x402AD89: malloc (vg_replace_malloc.c:236)
    ==9458==    by 0x4221A1F: vasprintf (vasprintf.c:78)
    ==9458==    by 0x40C6065: g_vasprintf (gprintf.c:314)
    ==9458==    by 0x409D894: g_strdup_vprintf (gstrfuncs.c:509)
    ==9458==    by 0x409D8C9: g_strdup_printf (gstrfuncs.c:535)
    ==9458==    by 0x40672E9: g_environ_setenv (genviron.c:156)
    ==9458==    by 0x80490E7: test_environ_array (environment.c:78)
    ==9458==    by 0x40A3DB5: test_case_run (gtestutils.c:1662)
    ==9458==    by 0x40A40B2: g_test_run_suite_internal (gtestutils.c:1715)
    ==9458==    by 0x40A417C: g_test_run_suite_internal (gtestutils.c:1726)
    ==9458==    by 0x40A42F9: g_test_run_suite (gtestutils.c:1771)
    ==9458==    by 0x40A3441: g_test_run (gtestutils.c:1319)
    ==9458==    by 0x80493F1: main (environment.c:108)
    
    Bug #669412.

 glib/genviron.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/glib/genviron.c b/glib/genviron.c
index b876451..edb10e5 100644
--- a/glib/genviron.c
+++ b/glib/genviron.c
@@ -198,6 +198,9 @@ g_environ_unsetenv (gchar       **envp,
           *f = *e;
           f++;
         }
+      else
+        g_free (*e);
+
       e++;
     }
   *f = NULL;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]