From 7217dd3b1beba4ebecf44840582656458ddf2969 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Tue, 29 Jul 2014 13:58:23 +0200 Subject: [PATCH] Statsd: avoid doing a division by zero when calculating the percentile with an empty histogram. --- 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 470fbb8d..dfdef611 100644 --- a/src/utils_latency.c +++ b/src/utils_latency.c @@ -227,7 +227,7 @@ cdtime_t latency_counter_get_percentile (latency_counter_t *lc, int sum; size_t i; - if ((lc == NULL) || !((percent > 0.0) && (percent < 100.0))) + if ((lc == NULL) || (lc->num == 0) || !((percent > 0.0) && (percent < 100.0))) return (0); /* Find index i so that at least "percent" events are within i+1 ms. */ -- 2.11.0