Fix assertion failure for bounded repeat of exactly MAX_REPEAT#456
Open
LuciferDono wants to merge 1 commit intointel:masterfrom
Open
Fix assertion failure for bounded repeat of exactly MAX_REPEAT#456LuciferDono wants to merge 1 commit intointel:masterfrom
LuciferDono wants to merge 1 commit intointel:masterfrom
Conversation
Pattern `abc .{0,32767}` causes an assertion failure in
ComponentRepeat::notePositions() because the assertion uses strict
less-than (m_max < MAX_REPEAT) while the constructor validates with
greater-than (m_max > MAX_REPEAT), creating an off-by-one gap at
exactly MAX_REPEAT (32767).
Change the assertion to use <= to match the constructor's boundary,
allowing the valid value of 32767 through without crashing.
Fixes intel#425
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.
Summary
Fixes an assertion failure (crash) when compiling a pattern with a bounded repeat of exactly 32767 (
MAX_REPEAT).The constructor in
ComponentRepeatvalidates withm_max > MAX_REPEAT, correctly allowing 32767 as a valid value. However, the assertion innotePositions()usesm_max < MAX_REPEAT, which rejects 32767 and triggers an abort.Fixes #425
Reproduction
{0,32766}compiles successfully{0,32768}returns a proper "Bounded repeat is too large" error{0,32767}crashes with:Assertion 'm_max == NoLimit || m_max < MAX_REPEAT' failedChange
One-character fix in
src/parser/ComponentRepeat.cpp:This makes the assertion consistent with the constructor's boundary validation on lines 71-76 of the same file.