Skip to content

regex: fix OOB bug discovered through ./v -g -force-bounds-checking test vlib/regex/#24960

Merged
spytheman merged 1 commit into
vlang:masterfrom
spytheman:potential_regex_bounds_check_fix
Jul 24, 2025
Merged

regex: fix OOB bug discovered through ./v -g -force-bounds-checking test vlib/regex/#24960
spytheman merged 1 commit into
vlang:masterfrom
spytheman:potential_regex_bounds_check_fix

Conversation

@spytheman

@spytheman spytheman commented Jul 23, 2025

Copy link
Copy Markdown
Contributor
  • regex: fix OOB bug discovered through ./v -g -force-bounds-checking vlib/regex/

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-23439

@spytheman spytheman changed the title potential regex bounds check fix regex: fix OOB bug discovered through ./v -g -force-bounds-checking test vlib/regex/ Jul 23, 2025
@penguindark

Copy link
Copy Markdown
Member

OK, I had a look at this, your solution can work but to avoid further problems I suggest to replace re.group_stack.clear() at line 356 with:

// restore initial state of the stack
for mut x in re.group_stack {
    x = -1
}

@spytheman spytheman force-pushed the potential_regex_bounds_check_fix branch from d56ade2 to 8699511 Compare July 24, 2025 04:20
@spytheman spytheman merged commit 93a1989 into vlang:master Jul 24, 2025
70 checks passed
@spytheman spytheman deleted the potential_regex_bounds_check_fix branch July 24, 2025 05:10
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.

2 participants