diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-20 09:46:12 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-20 09:46:12 +0000 |
commit | 8b8bb4ba01d9ea255db09ca0644fedf60771af3e (patch) | |
tree | 3f80c35e0674ffb0e56ff700aafe4a05983a931c /test | |
parent | aa60683970ed49fb2ec61790fb873f4b44569f19 (diff) | |
download | ruby-8b8bb4ba01d9ea255db09ca0644fedf60771af3e.tar.gz |
regparse.c: initialize return values
* regparse.c (parse_char_class): initialize return values before
depth limit check. returned values will be freed in callers
regardless the error. [ruby-core:79624] [Bug #13234]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_regexp.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index a9120149c5..112af60c96 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -1198,6 +1198,25 @@ class TestRegexp < Test::Unit::TestCase RUBY end + def test_invalid_free_at_parse_depth_limit_over + assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}") + begin; + begin + require '-test-/regexp' + rescue LoadError + else + bug = '[ruby-core:79624] [Bug #13234]' + Bug::Regexp.parse_depth_limit = 10 + src = "[" * 100 + 3.times do + assert_raise_with_message(RegexpError, /parse depth limit over/, bug) do + Regexp.new(src) + end + end + end + 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) |