[syslog-ng] [PATCH] value-pairs: Fix a double free on parse errors

Gergely Nagy algernon at balabit.hu
Wed Mar 14 10:31:26 CET 2012

In the command-line parser code, when we encountered an error, we
explicitly free'd the value-pairs structure, but did not return. A few
lines later, we called vp_cmdline_parse_rekey_finish(), which also tried
to free the same structure.

Instead, we should only call _rekey_finish() if we didn't NULL out the
value pairs structure earlier.

Signed-off-by: Gergely Nagy <algernon at balabit.hu>
 lib/value-pairs.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/value-pairs.c b/lib/value-pairs.c
index 12cf831..912164f 100644
--- a/lib/value-pairs.c
+++ b/lib/value-pairs.c
@@ -678,7 +678,8 @@ value_pairs_new_from_cmdline (GlobalConfig *cfg,
       vp = NULL;
   g_option_context_free (ctx);
-  vp_cmdline_parse_rekey_finish (user_data_args);
+  if (vp)
+    vp_cmdline_parse_rekey_finish (user_data_args);
   return vp;

More information about the syslog-ng mailing list