fix memory leak
authorChristian Grothoff <christian@grothoff.org>
Mon, 25 Jun 2018 18:12:58 +0000 (20:12 +0200)
committerChristian Grothoff <christian@grothoff.org>
Mon, 25 Jun 2018 18:12:58 +0000 (20:12 +0200)
src/util/gnunet-config.c

index 16b826ee2fa16b32f520afaafd0bed3f32defed9..532a5a0d6e481e07733c8cb28c5b9c340c5ff560 100644 (file)
@@ -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
   {