X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcollectd-nagios.c;h=8b0f867949e1f09c1b8f015598c8dd08e8d8925c;hb=49ac868d2346c77335272b8a643bca295db9feaa;hp=271909389cfcbf716cc5d1c2270a703bd2b29c04;hpb=f2389f97fbec15f49dcd1d9b06b3b6bbd0837e8a;p=collectd.git diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c index 27190938..8b0f8679 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 */