X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcollectd-nagios.c;h=7fda6fc120a3aa4c94eaa640092ab2ff39724f40;hb=f0b9430b0c0f45ada6f655dd4b9c64a8cbdf8d66;hp=e31d95ca31f3e52ebd2923e0482b3e7f7973f294;hpb=d6d42818a8794a756727a6bb56e3680c7eefd6f9;p=collectd.git diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index e31d95ca..7fda6fc1 100644 --- a/src/collectd-nagios.c +++ b/src/collectd-nagios.c @@ -303,8 +303,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); } @@ -318,6 +317,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; } @@ -325,8 +326,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 */