TheAlgorithms/Rust

Bug in `string/aho_corasick` algorithm

guopenghui opened this issue · 2 comments

ans.push(&s[i - len + 1..=i]);

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.

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

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.