Skip to content

Handle no dictionary words during pass 1 word recognition (issue #4448) #4449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sebras
Copy link

@sebras sebras commented Aug 9, 2025

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.

@sebras
Copy link
Author

sebras commented Aug 9, 2025

Please let me know if I made a mistake and help me rectify it. This is my first attempt at contributing to Tesseract. :)

Copy link
Contributor

@egorpugin egorpugin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just ->best_choice && ... is ok.

…eract-ocr#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 <sebras@gmail.com>
@sebras
Copy link
Author

sebras commented Aug 9, 2025

Just ->best_choice && ... is ok.

Aha! I'm not well versed in C++, so I just looked at nearby code and used their NULL-checks. I'll fix it in a jiffy. :)

@amitdo
Copy link
Collaborator

amitdo commented Aug 10, 2025

See my comments in issue #4448.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants