Skip to content

pat: treat {0,} quantifier as * to avoid nil-pointer panic#568

Merged
timbray merged 1 commit into
timbray:mainfrom
SAY-5:fix-min-zero-quantifier-panic
Jun 26, 2026
Merged

pat: treat {0,} quantifier as * to avoid nil-pointer panic#568
timbray merged 1 commit into
timbray:mainfrom
SAY-5:fix-min-zero-quantifier-panic

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #558. The isMinimumOnly branch in faFromQuantifiedAtom builds a chain of mandatory steps and then loops the last one back, but for {0,} the loop runs zero times, so lastState stays nil and the append on it panics. {0,} has no mandatory steps and means the same thing as *, so I handle that case the same way the * branch does.

Added an x{0,}y entry to regexpSamples (matches y/xy/xxxy, rejects x/z/xx); without the fix it panics during NFA construction.

Closes: timbray#558
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@timbray

timbray commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Thanks! First glance looks good. Heading into a busy weekend, may not get to a closer look for a couple days.

@timbray timbray left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Actually I realized how short it is, lgtm, thanks.

In future please sign your PRs, not with commit -s but by setting up a keypair with GitHub, years since I did it so I can't remember how but pretty straightforward I think.

@timbray timbray merged commit 81f5b73 into timbray:main Jun 26, 2026
7 checks passed
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.

regexp containing a{0,} can provoke a nil-pointer crash

2 participants