From: Christian Persch Date: Sun, 5 Feb 2012 15:00:31 +0000 (+0100) Subject: Plug a mem leak in g_environ_unsetenv X-Git-Tag: 2.31.18~103 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2f4b46e3783b04cddcb2622a57b2a8e692cff68a;p=platform%2Fupstream%2Fglib.git 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. --- 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;