Skip to content

Commit 09da044

Browse files
committed
Fix CID 1164553 (Division or modulo by float zero)
Signed-off-by: Stefan Weil <[email protected]>
1 parent 1b303e5 commit 09da044

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/ccmain/applybox.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,10 @@ void Tesseract::MaximallyChopWord(const GenericVector<TBOX>& boxes,
313313
/// miss metric gets the blob.
314314
static double BoxMissMetric(const TBOX& box1, const TBOX& box2) {
315315
const int overlap_area = box1.intersection(box2).area();
316-
double miss_metric = box1.area()- overlap_area;
317-
miss_metric /= box1.area();
318-
miss_metric *= box2.area() - overlap_area;
319-
miss_metric /= box2.area();
320-
return miss_metric;
316+
const int a = box1.area();
317+
const int b = box2.area();
318+
ASSERT_HOST(a != 0 && b != 0);
319+
return 1.0 * (a - overlap_area) * (b - overlap_area) / a / b;
321320
}
322321

323322
/// Gather consecutive blobs that match the given box into the best_state

0 commit comments

Comments
 (0)