summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-07-16 15:41:10 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-07-16 15:41:10 +0900
commit5c77402d885799e2465e291bf879dcfbd06ba77c (patch)
tree9ea230b5b0e5f7a445597a3cd53f3f5ab3fccc67 /test
parentda39936ce165ea9462b9e192eb6b608485c94842 (diff)
Fix null pointer access in Ripper#initialize
In `rb_ruby_ripper_parser_allocate`, `r->p` is NULL between creating `self` and `parser_params` assignment. As GC can happen there, the typed-data functions for it need to consider the case.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8085
Diffstat (limited to 'test')
-rw-r--r--test/ripper/test_ripper.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ripper/test_ripper.rb b/test/ripper/test_ripper.rb
index c6775c5c93..2bb307eddf 100644
--- a/test/ripper/test_ripper.rb
+++ b/test/ripper/test_ripper.rb
@@ -14,6 +14,13 @@ class TestRipper::Ripper < Test::Unit::TestCase
@ripper = Ripper.new '1 + 1'
end
+ def test_new
+ assert_separately(%w[-rripper], "#{<<~"begin;"}\n#{<<~'end;'}")
+ begin;
+ assert_nil EnvUtil.under_gc_stress {Ripper.new("")}.state
+ end;
+ end
+
def test_column
assert_nil @ripper.column
end