From 09559611ccf26d2817ad13425d3758a71faca4c8 Mon Sep 17 00:00:00 2001 From: Luca Deri Date: Fri, 19 Feb 2021 15:15:02 +0100 Subject: Fixes #1136 --- src/lib/ndpi_analyze.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c index 77400afd3..e142f914c 100644 --- a/src/lib/ndpi_analyze.c +++ b/src/lib/ndpi_analyze.c @@ -140,7 +140,8 @@ u_int32_t ndpi_data_max(struct ndpi_analyze_struct *s) { return(s->max_val); } /* Compute the variance on all values */ float ndpi_data_variance(struct ndpi_analyze_struct *s) { - return(s->num_data_entries ? ((float)s->stddev.sum_square_total - ((float)s->sum_total * (float)s->sum_total / (float)s->num_data_entries)) / (float)s->num_data_entries : 0.0); + float v = s->num_data_entries ? ((float)s->stddev.sum_square_total - ((float)s->sum_total * (float)s->sum_total / (float)s->num_data_entries)) / (float)s->num_data_entries : 0.0; + return((v < 0 /* rounding problem */) ? 0 : v); } /* ********************************************************************************* */ -- cgit v1.2.3