Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | Fix the memory leak problem when HAVE_ENVIRON is defined |
| 2 | |
| 3 | Upstream-Status: Pending |
| 4 | |
| 5 | Signed-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 | |