[syslog-ng] [PATCH 3/3] Fix the memory leak problem when HAVE_ENVIRON is defined

Xufeng Zhang xufeng.zhang at windriver.com
Mon Apr 14 08:24:17 CEST 2014


These memories are allocated in g_process_set_argv_space()
when HAVE_ENVIRON is defined, but are not freed anywhere.

Signed-off-by: Xufeng Zhang <xufeng.zhang at windriver.com>
---
 lib/gprocess.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/lib/gprocess.c b/lib/gprocess.c
index 9053bc9..6cc0b1f 100644
--- a/lib/gprocess.c
+++ b/lib/gprocess.c
@@ -1433,6 +1433,19 @@ 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();
 }
 
-- 
1.7.0.2



More information about the syslog-ng mailing list