Statsd: avoid doing a division by zero when calculating the percentile with an empty...
authorWilfried Goesgens <dothebart@citadel.org>
Tue, 29 Jul 2014 11:58:23 +0000 (13:58 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Tue, 29 Jul 2014 11:58:23 +0000 (13:58 +0200)
src/utils_latency.c

index bfe91fd..7699f57 100644 (file)
@@ -146,7 +146,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. */