X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fstatsd.c;h=5b7a6f182e7cef26af41b8db2baeb26c55f95b47;hb=0d80072344ea5322c34f716ed77a5319a62bfc96;hp=ea4123c10f6d38c6a731201981eb2aba7dff8d8c;hpb=aa958d2ad30d29553e489bc727254a8eedb4ea17;p=collectd.git diff --git a/src/statsd.c b/src/statsd.c index ea4123c1..5b7a6f18 100644 --- a/src/statsd.c +++ b/src/statsd.c @@ -127,14 +127,13 @@ static statsd_metric_t *statsd_metric_lookup_unsafe (char const *name, /* {{{ */ return (NULL); } - metric = malloc (sizeof (*metric)); + metric = calloc (1, sizeof (*metric)); if (metric == NULL) { - ERROR ("statsd plugin: malloc failed."); + ERROR ("statsd plugin: calloc failed."); sfree (key_copy); return (NULL); } - memset (metric, 0, sizeof (*metric)); metric->type = type; metric->latency = NULL; @@ -565,6 +564,7 @@ static int statsd_network_init (struct pollfd **ret_fds, /* {{{ */ if (tmp == NULL) { ERROR ("statsd plugin: realloc failed."); + close (fd); continue; } fds = tmp;