X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcollectd-nagios.c;h=7fda6fc120a3aa4c94eaa640092ab2ff39724f40;hb=cf6600eada442700263fabe0d58649363a456e88;hp=e31d95ca31f3e52ebd2923e0482b3e7f7973f294;hpb=912c9b3f7c4a57fbf9ddd16db13d2651932ddb65;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 */