From 4016dcd8e914a98301a737403b7fa1b38c02d4b4 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sat, 21 Jun 2014 21:14:28 +0200 Subject: [PATCH] Statsd: avoid doing a division by zero when calculating the average if we didn't get any values. --- src/utils_latency.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- 2.11.0