From: Otto Moerbeek Date: Fri, 29 Apr 2022 07:45:22 +0000 (+0200) Subject: Coverity 1401639 Division or modulo by float zero: avoid div by zero X-Git-Tag: auth-4.8.0-alpha0~116^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f17c3b1ce30a0b9610efd08190e95f4baf2be293;p=thirdparty%2Fpdns.git Coverity 1401639 Division or modulo by float zero: avoid div by zero --- diff --git a/pdns/dnsreplay.cc b/pdns/dnsreplay.cc index 0d4b8d1001..8b9c55b547 100644 --- a/pdns/dnsreplay.cc +++ b/pdns/dnsreplay.cc @@ -296,6 +296,10 @@ static uint64_t countLessThan(unsigned int msec) static void emitFlightTimes() { uint64_t totals = countLessThan(flightTimes.size()); + if (totals == 0) { + // Avoid division by zero below + totals = 1; + } unsigned int limits[]={1, 2, 3, 4, 5, 10, 20, 30, 40, 50, 100, 200, 500, 1000, (unsigned int) flightTimes.size()}; uint64_t sofar=0; cout.setf(std::ios::fixed);