From 9be428429d2b3a11423df18d3e2d27f24bbe4458 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 25 Jun 2018 20:12:58 +0200 Subject: [PATCH] fix memory leak --- src/util/gnunet-config.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c index 16b826ee2..532a5a0d6 100644 --- a/src/util/gnunet-config.c +++ b/src/util/gnunet-config.c @@ -75,20 +75,29 @@ print_option (void *cls, const char *option, const char *value) { - (void) section; const struct GNUNET_CONFIGURATION_Handle *cfg = cls; - char *value_fn; + + (void) section; if (is_filename) { + char *value_fn; + char *fn; + GNUNET_assert (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_filename (cfg, - section, - option, - &value_fn)); + GNUNET_CONFIGURATION_get_value_filename (cfg, + section, + option, + &value_fn)); + fn = GNUNET_STRINGS_filename_expand (value_fn); + if (NULL == fn) + fn = value_fn; + else + GNUNET_free (value_fn); fprintf (stdout, - "%s = %s\n", - option, - GNUNET_STRINGS_filename_expand (value_fn)); + "%s = %s\n", + option, + fn); + GNUNET_free (fn); } else { -- 2.25.1