Bug in `string/aho_corasick` algorithm

2
closed
guopenghui
guopenghui
Posted 11 months ago

Bug in `string/aho_corasick` algorithm #319

https://github.com/TheAlgorithms/Rust/blob/a5cf37c397d097305f52736d6305d22f22b7b82a/src/string/aho_corasick.rs#L80

It will cause computing overflow when pattern appear at head of string.

If i - len + 1 == 0, i - len will be -1 first, then panic.

Change to i + 1 - len will solve this.

siriak
siriak
Created 10 months ago

Thanks for reporting, could you make a PR with the proposed changes?

github-actions[bot]
github-actions[bot]
Created 9 months ago

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.