diff options
author | Hiroya Fujinami <[email protected]> | 2025-05-16 10:14:26 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2025-05-16 10:14:26 +0900 |
commit | 35000ac2ed3a1829f8d193ffb23da0e44cc6fe5f (patch) | |
tree | c3430ab96d4cf63f89b1bebd0603266b9c391df8 /test/ruby/test_regexp.rb | |
parent | 6b10d40157b5287cd13169437800343165eae949 (diff) |
Prevent double free for too big repetition quantifiers (#13332)
Prevent double free for too big repetition quantifiers
The previous implementation calls `free(node)` twice (on parsing and compiling a
regexp) when it has an error, so it leads to a double-free issue. This
commit enforces `free(node)` once by introducing a temporal pointer to hold
parsing nodes.
Notes
Notes:
Merged-By: makenowjust <[email protected]>
Diffstat (limited to 'test/ruby/test_regexp.rb')
-rw-r--r-- | test/ruby/test_regexp.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 78269f8e9a..65f1369a0f 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1875,6 +1875,12 @@ class TestRegexp < Test::Unit::TestCase end; end + def test_too_big_number_for_repeat_range + assert_raise_with_message(SyntaxError, /too big number for repeat range/) do + eval(%[/|{1000000}/]) + end + end + # This assertion is for porting x2() tests in testpy.py of Onigmo. def assert_match_at(re, str, positions, msg = nil) re = Regexp.new(re) unless re.is_a?(Regexp) |