From 8b0036c19e64329a21cb1d4230e5a8b504df0878 Mon Sep 17 00:00:00 2001 From: Sebastian Rasmussen Date: Sat, 9 Aug 2025 03:49:35 +0200 Subject: [PATCH] Handle no dictionary words during pass 1 word recognition (issue #4448) Previously if page_res_it.word()->best_choice == nullptr, dereferencing it in page_res_it.word()->best_choice->permuter() caused a segmentation fault. By checking best_choice != nullptr, i.e. there is a dictionary word, before dereferencing it, the crash is avoided. Signed-off-by: Sebastian Rasmussen --- src/ccmain/control.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ccmain/control.cpp b/src/ccmain/control.cpp index 454aa94f2a..7259b28e69 100644 --- a/src/ccmain/control.cpp +++ b/src/ccmain/control.cpp @@ -353,7 +353,7 @@ bool Tesseract::recog_all_words(PAGE_RES *page_res, ETEXT_DESC *monitor, } // Count dict words. - if (page_res_it.word()->best_choice->permuter() == USER_DAWG_PERM) { + if (page_res_it.word()->best_choice && page_res_it.word()->best_choice->permuter() == USER_DAWG_PERM) { ++(stats_.dict_words); }