automata: fix onepass::DFA::try_search_slots panic when too many slots are given#1330
Merged
BurntSushi merged 1 commit intomasterfrom Feb 3, 2026
Merged
automata: fix onepass::DFA::try_search_slots panic when too many slots are given#1330BurntSushi merged 1 commit intomasterfrom
onepass::DFA::try_search_slots panic when too many slots are given#1330BurntSushi merged 1 commit intomasterfrom
Conversation
f03bef3 to
685c875
Compare
685c875 to
fde882c
Compare
…ots are given The API specifically documents that the caller may provide *any* number of slots. But the onepass implementation was panicking when too many were provided. (I had only considered the case when too few were provided when I wrote one-pass implementation I think.) This already works for the PikeVM and the bounded backtracker. This commit adds tests covering those as well. Note that the bug report specifically cites a zero-repetition capture group as the instigator here. While that may have provided the circumstances for the bug to appear, the actual bug is more general than that. You don't need any capture groups at all to provoke it. You just need to provide more slots than there are in the compiled regex. Fixes #1327, Closes #1329
fde882c to
9369075
Compare
Member
Author
|
This PR is on crates.io in |
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.
The API specifically documents that the caller may provide any number
of slots. But the onepass implementation was panicking when too many
were provided. (I had only considered the case when too few were
provided when I wrote one-pass implementation I think.)
This already works for the PikeVM and the bounded backtracker. This
commit adds tests covering those as well.
Note that the bug report specifically cites a zero-repetition capture
group as the instigator here. While that may have provided the
circumstances for the bug to appear, the actual bug is more general than
that. You don't need any capture groups at all to provoke it. You just
need to provide more slots than there are in the compiled regex.
Fixes #1327, Closes #1329