From 804ef69e8163aa3de6652d52f89935444accbb4f 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 94da2112..bfe91fd8 100644 --- a/src/utils_latency.c +++ b/src/utils_latency.c @@ -128,7 +128,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