re.c: check that MatchData is initialized

Follow r16757 ("* re.c: fix SEGV by Regexp.allocate.names,
Match.allocate.names, etc.", 2008-06-02). Don't do null dereference if
MatchData#hash or #== is called against an uninitialized instance.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
rhe 2016-12-06 06:14:17 +00:00
parent 2a45604772
commit d802149be3
2 changed files with 5 additions and 1 deletions

View file

@ -946,6 +946,7 @@ class TestRegexp < Test::Unit::TestCase
assert_raise(TypeError) { Regexp.allocate.names }
assert_raise(TypeError) { Regexp.allocate.named_captures }
assert_raise(TypeError) { MatchData.allocate.hash }
assert_raise(TypeError) { MatchData.allocate.regexp }
assert_raise(TypeError) { MatchData.allocate.names }
assert_raise(TypeError) { MatchData.allocate.size }