From 30d691f576a7c1327cfd88269aa025747aee6083 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 10 Mar 2017 17:25:16 +0100 Subject: [PATCH] handle case 'diff' is NULL - fixes NPE --- src/nat-auto/gnunet-nat-auto.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/nat-auto/gnunet-nat-auto.c b/src/nat-auto/gnunet-nat-auto.c index 9ba81eb5f..5eb0a4be3 100644 --- a/src/nat-auto/gnunet-nat-auto.c +++ b/src/nat-auto/gnunet-nat-auto.c @@ -174,6 +174,9 @@ auto_config_cb (void *cls, GNUNET_NAT_AUTO_status2string (result), nat_type); + if (NULL == diff) + return; + /* Shortcut: if there are no changes suggested, bail out early. */ if (GNUNET_NO == GNUNET_CONFIGURATION_is_dirty (diff)) @@ -186,20 +189,16 @@ auto_config_cb (void *cls, to the user */ new_cfg = write_cfg ? GNUNET_CONFIGURATION_dup (cfg) : NULL; - if (NULL != diff) - { - GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, - _("Suggested configuration changes:\n")); - GNUNET_CONFIGURATION_iterate_section_values (diff, - "nat", - &auto_conf_iter, - new_cfg); - } + GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, + _("Suggested configuration changes:\n")); + GNUNET_CONFIGURATION_iterate_section_values (diff, + "nat", + &auto_conf_iter, + new_cfg); /* If desired, write configuration to file; we write only the changes to the defaults to keep things compact. */ - if ( (write_cfg) && - (NULL != diff) ) + if (write_cfg) { struct GNUNET_CONFIGURATION_Handle *def_cfg; @@ -298,8 +297,8 @@ run (void *cls, if (do_auto) { ah = GNUNET_NAT_AUTO_autoconfig_start (c, - &auto_config_cb, - NULL); + &auto_config_cb, + NULL); } if (use_tcp && use_udp) -- 2.25.1