Statsd: avoid doing a division by zero when calculating the average if we didn't...
[collectd.git] / src / utils_latency.c
index 96ce8e3..470fbb8 100644 (file)
@@ -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);