]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Coverity 1401639 Division or modulo by float zero: avoid div by zero
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 29 Apr 2022 07:45:22 +0000 (09:45 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 29 Apr 2022 07:52:09 +0000 (09:52 +0200)
pdns/dnsreplay.cc

index 0d4b8d10014f7bb6bb05ac8c33002057d289e5e4..8b9c55b547dd6dc10c857523850de9a9a5374f0a 100644 (file)
@@ -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);