From: Wilfried Goesgens Date: Sat, 21 Jun 2014 19:14:28 +0000 (+0200) Subject: Statsd: avoid doing a division by zero when calculating the average if we didn't... X-Git-Tag: collectd-5.5.0~12^2~16 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4016dcd8e914a98301a737403b7fa1b38c02d4b4;p=collectd.git Statsd: avoid doing a division by zero when calculating the average if we didn't get any values. --- diff --git a/src/utils_latency.c b/src/utils_latency.c index 96ce8e31..470fbb8d 100644 --- a/src/utils_latency.c +++ b/src/utils_latency.c @@ -209,7 +209,7 @@ cdtime_t latency_counter_get_average (latency_counter_t *lc) /* {{{ */ { double average; - if (lc == NULL) + if ((lc == NULL) || (lc->num == 0)) return (0); average = CDTIME_T_TO_DOUBLE (lc->sum) / ((double) lc->num);