diff --git a/src/collectd-nagios.c b/src/collectd-nagios.c
index 271909389cfcbf716cc5d1c2270a703bd2b29c04..8b0f867949e1f09c1b8f015598c8dd08e8d8925c 100644 (file)
--- a/src/collectd-nagios.c
+++ b/src/collectd-nagios.c
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);
}
printf ("ERROR: listval: Failed to convert returned "
"identifier to a string: %s\n",
lcc_strerror (connection));
+ free (hostname);
+ hostname = NULL;
continue;
}
printf ("\t%s\n", id + 1);
}
- if (ret_ident != NULL)
- free (ret_ident);
+ free (ret_ident);
+ free (hostname);
return (RET_OKAY);
} /* int do_listval */