Skip to content

Commit eaabe4a

Browse files
committed
ErrorCounter: Fix CID 1164538 (Division or modulo by float zero)
Signed-off-by: Stefan Weil <[email protected]>
1 parent 8f615d4 commit eaabe4a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/classify/errorcounter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ double ErrorCounter::ComputeErrorRate(ShapeClassifier* classifier,
4646
GenericVector<UnicharRating> results;
4747

4848
clock_t start = clock();
49-
int total_samples = 0;
49+
unsigned total_samples = 0;
5050
double unscaled_error = 0.0;
5151
// Set a number of samples on which to run the classify debug mode.
5252
int error_samples = report_level > 3 ? report_level * report_level : 0;
@@ -89,7 +89,7 @@ double ErrorCounter::ComputeErrorRate(ShapeClassifier* classifier,
8989
fontinfo_table,
9090
*it, unichar_error, fonts_report);
9191
if (scaled_error != nullptr) *scaled_error = counter.scaled_error_;
92-
if (report_level > 1) {
92+
if (report_level > 1 && total_samples > 0) {
9393
// It is useful to know the time in microseconds/char.
9494
tprintf("Errors computed in %.2fs at %.1f μs/char\n",
9595
total_time, 1000000.0 * total_time / total_samples);

0 commit comments

Comments
 (0)