Commit 1c6d2d29 for tesseract
commit 1c6d2d29b2af2645f939121c158f7d4a4452c749
Author: Stefan Weil <sw@weilnetz.de>
Date: Fri Nov 13 21:26:30 2026 +0100
textord: count the rows with 32 bits in assign_blobs_to_rows
row_count was an int16_t. In the first pass each blob which fits no
existing row starts a new row, and a page close to the largest width
can get more than 65335 rows that way. The counter wrapped to -200
then, which makes the divisor
row_count * textord_skew_lag + textord_skewsmooth_offset exactly zero
with the default parameters. The tesseract executable traps that
division when it was built with g++ (SIGFPE), other programs continue
with an infinite smooth factor.
Use int32_t for row_count, and also for the row count in
compute_row_stats(), which is used for the size of a vector.
The scanner reported this without a patch. The change is the one
which the report suggests.
Reported by the Anthropic OSS Scanner (finding ANT-2026-ULPIXPFB).
Assisted-by: OpenCode / Claude Fable 5.2 (Anthropic)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
diff --git a/src/textord/makerow.cpp b/src/textord/makerow.cpp
index d506b281..a7070578 100644
--- a/src/textord/makerow.cpp
+++ b/src/textord/makerow.cpp
@@ -1169,7 +1169,7 @@ void compute_row_stats( // find lines
float iqr; // inter quartile range
TO_ROW_IT row_it = block->get_rows();
// number of rows
- int16_t rowcount = row_it.length();
+ int32_t rowcount = row_it.length();
// for choose nth
std::vector<TO_ROW *> rows(rowcount);
rowcount = 0;
@@ -2296,7 +2296,7 @@ void assign_blobs_to_rows( // find lines
float ycoord; // current y
float top, bottom; // of blob
float g_length = 1.0f; // from gradient
- int16_t row_count; // no of rows
+ int32_t row_count; // no of rows
int16_t left_x; // left edge
int16_t last_x; // previous edge
float block_skew; // y delta