Commit e8681b5d for tesseract
commit e8681b5dad5d854b166b4d6dc2b37e7d647bb6a4
Author: Stefan Weil <sw@weilnetz.de>
Date: Fri Nov 13 17:30:08 2026 +0100
ccmain: do not abort on an unsupported tessedit_reject_mode
make_reject_map() only supports the values 0 and 5 for
tessedit_reject_mode and called ASSERT_HOST for any other value. That
aborted the process, also for users of the library, as soon as the
legacy engine recognized the first word.
Print a warning and use the default mode instead.
Fix proposed by the Anthropic OSS Scanner (finding ANT-2026-W4VDS3BJ).
Assisted-by: OpenCode / Claude Fable 5.2 (Anthropic)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
diff --git a/src/ccmain/reject.cpp b/src/ccmain/reject.cpp
index f9c8c771..6c2fc05b 100644
--- a/src/ccmain/reject.cpp
+++ b/src/ccmain/reject.cpp
@@ -99,6 +99,13 @@ void Tesseract::make_reject_map(WERD_RES *word, int16_t pass) {
set_done(word, pass); // Set acceptance
word->reject_map.initialise(word->best_choice->unichar_lengths().length());
reject_blanks(word);
+ if (tessedit_reject_mode != 0 && tessedit_reject_mode != 5) {
+ // The value may come from a config file or from the config embedded in
+ // the traineddata, so it must not be fatal. Fall back to the default.
+ tprintf("Warning: unsupported tessedit_reject_mode %d, using the default\n",
+ static_cast<int>(tessedit_reject_mode));
+ tessedit_reject_mode.ResetToDefault();
+ }
/*
0: Rays original heuristic - the baseline
*/
@@ -158,9 +165,6 @@ void Tesseract::make_reject_map(WERD_RES *word, int16_t pass) {
}
/* Ambig word rejection was here once !!*/
}
- } else {
- tprintf("BAD tessedit_reject_mode\n");
- ASSERT_HOST("Fatal error encountered!" == nullptr);
}
if (tessedit_image_border > -1) {