Fix out-of-bounds access in Levenshtein edit distance #15
Merged
jakob-schuster merged 2 commits intoDec 22, 2025
Conversation
Contributor
Author
|
This bug fix works well for now. restrander/src/ukkonenMatch.cpp Lines 114 to 123 in 9fe4320 |
…f size m rather than array. (Vectors have certain extra memory overhead and allow for easier resizing or bounds checking). Prev C[m] array size is m (0...m-1) in the loop, C[lact] when lact == m or C[i] when lact == m, will trigger out of bound value leads to oscillation between 2 stable outcome due to neg value < threshold
7f68b8d to
1c6ad87
Compare
Contributor
Author
|
@jakob-schuster , could you please let me know your thoughts when you have time? thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix out-of-bounds access in Levenshtein edit distance by using vector C of size m rather than array. (Vectors have certain extra memory overhead and allow for easier resizing or bounds checking).
Prev C[m] array size is m (0...m-1)
in the loop, C[lact] when lact == m or C[i] when lact == m, will trigger out of bound value leads to oscillation between 2 stable outcome due to neg value < threshold
Example debugging trace data before bug fix
Barcode size = 15, pos 812 trigger a false match due to C[m] out of bound (~50% as neg value) < threshold
The other 50%, the out of bound report a large positive value and pos 812 is not matched.
After bug fix, C[m] out of bound issue is resolved