blob: 2ac9c0be0f70124aa4446be350e738966136cfd3 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001Fix the memory leak problem when HAVE_ENVIRON is defined
2
3Upstream-Status: Pending
4
5Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com>
6---
7--- a/lib/gprocess.c
8+++ b/lib/gprocess.c
9@@ -1421,6 +1421,18 @@
10 void
11 g_process_finish(void)
12 {
13+#ifdef HAVE_ENVIRON
14+ int i = 0;
15+
16+ while (environ[i]) {
17+ g_free(environ[i]);
18+ ++i;
19+ }
20+ if (environ)
21+ g_free(environ);
22+ if (process_opts.argv_orig)
23+ free(process_opts.argv_orig);
24+#endif
25 g_process_remove_pidfile();
26 }
27