X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcollectd-nagios.c;h=b17e47e2e1618949772dd3ccfd3db592ddf643ca;hb=0532336600cf2abe1d25af8fbf5ad3cf3b6b31e0;hp=3d6039c47d519d7b3f8e6d217c7d65882c7b74bc;hpb=1e34eeecc5939118e644be5337612a0326781f8e;p=collectd.git diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index 3d6039c4..b17e47e2 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -308,8 +308,7 @@ static int do_listval (lcc_connection_t *connection) if ((hostname == NULL) || strcasecmp (hostname, ret_ident[i].host)) { - if (hostname != NULL) - free (hostname); + free (hostname); hostname = strdup (ret_ident[i].host); printf ("Host: %s\n", hostname); } @@ -323,6 +322,8 @@ static int do_listval (lcc_connection_t *connection) printf ("ERROR: listval: Failed to convert returned " "identifier to a string: %s\n", lcc_strerror (connection)); + free (hostname); + hostname = NULL; continue; } @@ -330,8 +331,8 @@ static int do_listval (lcc_connection_t *connection) printf ("\t%s\n", id + 1); } - if (ret_ident != NULL) - free (ret_ident); + free (ret_ident); + free (hostname); return (RET_OKAY); } /* int do_listval */