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

fix(script_translator): correction can cause segfault #863

Merged
merged 5 commits into from
Apr 21, 2024

Conversation

ksqsf
Copy link
Member

@ksqsf ksqsf commented Apr 18, 2024

Previously, the correction count limit doesn't really work, and it will take all candidates. When finding the candidates for the last page, ScriptTranslation::PrepareCandidate can return nullptr, leading to segfault.

Pull request

Issue tracker

Fixes will automatically close the related issue

Fixes #

Feature

Describe feature of pull request

Unit test

  • Done

Manual test

  • Done

Code Review

  1. Unit and manual test pass
  2. GitHub Action CI pass
  3. At least one contributor reviews and votes
  4. Can be merged clean without conflicts
  5. PR will be merged by rebase upstream base

Additional Info

ksqsf added 2 commits April 18, 2024 20:47
Previously, the correction count limit doesn't really work, and it
will take all candidates. When finding the candidates for the last
page, ScriptTranslation::PrepareCandidate can return nullptr, leading
to segfault.
@ksqsf ksqsf requested a review from lotem April 18, 2024 13:07
@@ -431,7 +431,7 @@ bool ScriptTranslation::Next() {
} while (enable_correction_ &&
syllabifier_->IsCandidateCorrection(*candidate_) &&
// limit the number of correction candidates
++correction_count_ > max_corrections_);
Copy link
Member

@lotem lotem Apr 18, 2024

Choose a reason for hiding this comment

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

This while-loop is used to drop any correction candidates after the top N (max_corrections_).

If I didn't take it wrong, correction_count_ > max_corrections_ means exactly "correction candidates after the top N" so the loop goes on until the next non-correction candidate is found.

I recently updated this part. I might have broken it. Please blame and review my last change.
One thing that appear weird is the is_correction never set true.

lotem added 3 commits April 21, 2024 23:51
it is the correct logic to discard more correction candidates after the top N;
if reverted, all correction candidates except the top N are displayed.
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.

2 participants