Skip to content

Commit

Permalink
Merge pull request #3227 from ruby/pz-regexp-uninit-val
Browse files Browse the repository at this point in the history
Fix use of uninitialized value when parsing regexp
  • Loading branch information
eileencodes authored Nov 12, 2024
2 parents ed36c4a + be6cbc2 commit e4ec598
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/regexp.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ pm_regexp_parse_range_quantifier(pm_regexp_parser_t *parser) {
} state = PM_REGEXP_RANGE_QUANTIFIER_STATE_START;

while (1) {
if (parser->cursor >= parser->end) {
parser->cursor = savepoint;
return true;
}

switch (state) {
case PM_REGEXP_RANGE_QUANTIFIER_STATE_START:
switch (*parser->cursor) {
Expand Down
4 changes: 4 additions & 0 deletions test/prism/regexp_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ def test_fake_range_quantifier_because_of_spaces
assert_valid_regexp("foo{1, 2}")
end

def test_fake_range_quantifier_because_unclosed
assert_valid_regexp("\\A{")
end

############################################################################
# These test that flag values are correct.
############################################################################
Expand Down

0 comments on commit e4ec598

Please sign in to comment.