diff options
| author | NARUSE, Yui <naruse@airemix.jp> | 2024-01-30 20:29:02 +0900 |
|---|---|---|
| committer | NARUSE, Yui <naruse@airemix.jp> | 2024-01-30 20:29:02 +0900 |
| commit | f585171a6b1d6c20b3c162fd59dc874510ed2a49 (patch) | |
| tree | 3024caed094a7d7439aed211fc538181720d5a3f /test/ruby | |
| parent | f8f0d342e48a38caac6d32b438c145bb581a51e6 (diff) | |
merge revision(s) e12d4c654e3cb7a4473014610bc3bae41aaf811e: [Backport #20104]
Don't create T_MATCH object if /regexp/.match(string) doesn't match
Fixes [Bug #20104]
---
re.c | 9 ++++++---
test/ruby/test_regexp.rb | 12 ++++++++++++
tool/lib/envutil.rb | 8 ++++++++
3 files changed, 26 insertions(+), 3 deletions(-)
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_regexp.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index b889b1a64e..43357b0c64 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -711,6 +711,18 @@ class TestRegexp < Test::Unit::TestCase } end + def test_match_no_match_no_matchdata + EnvUtil.without_gc do + h = {} + ObjectSpace.count_objects(h) + prev_matches = h[:T_MATCH] || 0 + md = /[A-Z]/.match('1') # no match + ObjectSpace.count_objects(h) + new_matches = h[:T_MATCH] || 0 + assert_equal prev_matches, new_matches, "Bug [#20104]" + end + end + def test_initialize assert_raise(ArgumentError) { Regexp.new } assert_equal(/foo/, assert_warning(/ignored/) {Regexp.new(/foo/, Regexp::IGNORECASE)}) |
