From 0846c2da457e7523819236ac7da492029b3ef73d Mon Sep 17 00:00:00 2001 From: "xtkoba (Tee KOBAYASHI)" Date: Mon, 15 Mar 2021 10:15:10 +0900 Subject: Check backref number buffer overrun [Bug #16376] --- test/ruby/test_regexp.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test') diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 495c9de919..65ee0e4197 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1312,6 +1312,12 @@ class TestRegexp < Test::Unit::TestCase assert_nil($1) end + def test_backref_overrun + assert_raise_with_message(SyntaxError, /invalid backref number/) do + eval(%["".match /(())(?)((?(90000)))/]) + 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) -- cgit v1.2.3