From f17c3b1ce30a0b9610efd08190e95f4baf2be293 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 29 Apr 2022 09:45:22 +0200 Subject: [PATCH] Coverity 1401639 Division or modulo by float zero: avoid div by zero --- pdns/dnsreplay.cc | 4 ++++ 1 file changed, 4 insertions(+) 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); -- 2.47.3