From d385b49f5fe869ac746f59bcde35fa619af59ed5 Mon Sep 17 00:00:00 2001 From: Quantum Date: Mon, 28 Jun 2021 00:22:25 -0400 Subject: [PATCH] [common] runningavg: avoid integer overflows We receive values as int64_t, but when we compute the sum, we store it as int. This doesn't make sense as we eventually cast it to double when computing the average. We should instead store the sum as int64_t. --- common/src/runningavg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/runningavg.c b/common/src/runningavg.c index c7e289c2..66a1ea23 100644 --- a/common/src/runningavg.c +++ b/common/src/runningavg.c @@ -26,7 +26,7 @@ struct RunningAvg { int length, samples; int pos; - int value; + int64_t value; int64_t values[0]; };