From c3284526871f164de42227a3cb466cd3f2f2a335 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 29 Aug 2019 16:08:18 +0200 Subject: Average calculation fix --- src/lib/ndpi_analyze.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c index 8facdf371..eb36cb516 100644 --- a/src/lib/ndpi_analyze.c +++ b/src/lib/ndpi_analyze.c @@ -89,7 +89,7 @@ void ndpi_data_add_value(struct ndpi_analyze_struct *s, const u_int32_t value) { /* Compute the average on all values */ float ndpi_data_average(struct ndpi_analyze_struct *s) { - return((float)s->sum_total / (float)s->num_data_entries); + return((s->num_data_entries == 0) ? 0 : ((float)s->sum_total / (float)s->num_data_entries)); } /* ********************************************************************************* */ -- cgit v1.2.3