Skip to content
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

ChoiceIterator: skip symbol without choices #2871

Merged
merged 1 commit into from
Jan 24, 2020

Conversation

bertsky
Copy link
Contributor

@bertsky bertsky commented Jan 24, 2020

This fixes a segfault when running with lstm_choice_mode=2 and querying the choice iterator.

Copy link
Contributor

@stweil stweil left a comment

Choose a reason for hiding this comment

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

Yes, this will fix the crash caused by an empty first alternative. This would also fix it:

 if (word_res_->CTC_symbol_choices[0].empty() ||
     strcmp(word_res_->CTC_symbol_choices[0][0].first, " ")) {

Are you sure that your fix is the right one? And I wonder whether symbols without a choice may exist at all or whether there is a bug somewhere else.

@bertsky
Copy link
Contributor Author

bertsky commented Jan 24, 2020

This would also fix it:

 if (word_res_->CTC_symbol_choices[0].empty() ||
     strcmp(word_res_->CTC_symbol_choices[0][0].first, " ")) {

Indeed it would. It's not the same thing (blanks_before_word_ from the normal iterator would not always be skipped), and I have not tested your variant.

Are you sure that your fix is the right one? And I wonder whether symbols without a choice may exist at all or whether there is a bug somewhere else.

Probably just a follow-up, yes.

@stweil stweil merged commit 78fc00a into tesseract-ocr:master Jan 24, 2020
kba added a commit to OCR-D/ocrd_all that referenced this pull request Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants