[PATCH v1 1/2] ReportsBase.cc: Remove possible division by zero

Ryan Long ryan.long at oarcorp.com
Tue Jun 29 17:06:11 UTC 2021


CID 1503709: Division or modulo by float zero

Closes #4415
---
 tester/covoar/ReportsBase.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
index b4a755c..31dc429 100644
--- a/tester/covoar/ReportsBase.cc
+++ b/tester/covoar/ReportsBase.cc
@@ -482,9 +482,13 @@ void  ReportsBase::WriteSummaryReport(
     }
   }
 
-  percentage = (double) notExecuted;
-  percentage /= (double) totalBytes;
-  percentage *= 100.0;
+  if (totalBytes == 0) {
+    percentage = 0;
+  } else {
+    percentage = (double) notExecuted;
+    percentage /= (double) totalBytes;
+    percentage *= 100.0;
+  }
 
   percentageBranches = (double) (
     SymbolsToAnalyze->getNumberBranchesAlwaysTaken(symbolSetName) +
-- 
1.8.3.1



More information about the devel mailing list