Fix the memory leak problem when HAVE_ENVIRON is defined

Upstream-Status: Pending

Signed-off-by: Xufeng Zhang <xufeng.zhang@windriver.com>
---
Index: syslog-ng-3.8.1/lib/gprocess.c
===================================================================
--- syslog-ng-3.8.1.orig/lib/gprocess.c
+++ syslog-ng-3.8.1/lib/gprocess.c
@@ -1432,6 +1432,18 @@ g_process_startup_ok(void)
 void
 g_process_finish(void)
 {
+#ifdef HAVE_ENVIRON
+  int i = 0;
+
+  while (environ[i]) {
+    g_free(environ[i]);
+    ++i;
+  }
+  if (environ)
+    g_free(environ);
+  if (process_opts.argv_orig)
+    free(process_opts.argv_orig);
+#endif
   g_process_remove_pidfile();
 }
 
