From d1e7344f16d5765ec2a675162a88983bd51baa1d Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 7 Jan 2019 18:26:28 +0100 Subject: [PATCH] ClockEstimate: DivByZero The clock estimator has a potential division by zero. Using `iteration + 1` seems also more logical to me for an average. Found with coverity in a downstream project. --- include/internal/catch_timer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/internal/catch_timer.cpp b/include/internal/catch_timer.cpp index d52c0085..ca383a2d 100644 --- a/include/internal/catch_timer.cpp +++ b/include/internal/catch_timer.cpp @@ -40,7 +40,7 @@ namespace Catch { // is terrible and we should move on. // TBD: How to signal that the measured resolution is probably wrong? if (ticks > startTime + 3 * nanosecondsInSecond) { - return sum / i; + return sum / ( i + 1u ); } }