X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcollectd-nagios.c;h=b17e47e2e1618949772dd3ccfd3db592ddf643ca;hb=75323bd2ca5e0fdb8d93b34e7d9b8effac972697;hp=3d6039c47d519d7b3f8e6d217c7d65882c7b74bc;hpb=bf1613564dfcb0a517b77d658a844ea37b45803f;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 */