Commit 7f76d8ec for tesseract
commit 7f76d8ecbfe978c478eeae7821011c34b4e685aa
Author: Stefan Weil <sw@weilnetz.de>
Date: Fri Nov 13 21:26:30 2026 +0100
ccstruct: count the votes for an inverse word with int
WERD::WERD() counted the inverted and the other blobs of a word in
two int16_t variables. For a word with 32768 or more blobs the count
of the normal blobs wrapped to a negative value, so the word was
flagged as inverse and all its blobs were moved to the rejected
blobs. ComputeBlobEnds() then used the first element of the empty
blob list (null pointer).
Use int for both counters.
Fix proposed by the Anthropic OSS Scanner (finding ANT-2026-9RS8H8TA).
Assisted-by: OpenCode / Claude Fable 5.2 (Anthropic)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
diff --git a/src/ccstruct/werd.cpp b/src/ccstruct/werd.cpp
index 287c82f2..43cb7b92 100644
--- a/src/ccstruct/werd.cpp
+++ b/src/ccstruct/werd.cpp
@@ -47,8 +47,8 @@ WERD::WERD(C_BLOB_LIST *blob_list, uint8_t blank_count, const char *text)
C_BLOB_IT start_it = &cblobs;
C_BLOB_IT rej_cblob_it = &rej_cblobs;
C_OUTLINE_IT c_outline_it;
- int16_t inverted_vote = 0;
- int16_t non_inverted_vote = 0;
+ int inverted_vote = 0;
+ int non_inverted_vote = 0;
// Move blob_list's elements into cblobs.
start_it.add_list_after(blob_list);