From eaabe4a3cedc44f2029778a635a3f6a1a1e6b47a Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 22 Oct 2018 20:43:43 +0200 Subject: [PATCH] ErrorCounter: Fix CID 1164538 (Division or modulo by float zero) Signed-off-by: Stefan Weil --- src/classify/errorcounter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/classify/errorcounter.cpp b/src/classify/errorcounter.cpp index 65b36b7f6d..9e07964994 100644 --- a/src/classify/errorcounter.cpp +++ b/src/classify/errorcounter.cpp @@ -46,7 +46,7 @@ double ErrorCounter::ComputeErrorRate(ShapeClassifier* classifier, GenericVector results; clock_t start = clock(); - int total_samples = 0; + unsigned total_samples = 0; double unscaled_error = 0.0; // Set a number of samples on which to run the classify debug mode. int error_samples = report_level > 3 ? report_level * report_level : 0; @@ -89,7 +89,7 @@ double ErrorCounter::ComputeErrorRate(ShapeClassifier* classifier, fontinfo_table, *it, unichar_error, fonts_report); if (scaled_error != nullptr) *scaled_error = counter.scaled_error_; - if (report_level > 1) { + if (report_level > 1 && total_samples > 0) { // It is useful to know the time in microseconds/char. tprintf("Errors computed in %.2fs at %.1f μs/char\n", total_time, 1000000.0 * total_time / total_samples);