summaryrefslogtreecommitdiff
path: root/test/ruby/test_enum.rb
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-12-15 08:28:52 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-12-15 08:28:52 +0000
commitfd3c731a31bfed559af8bd9e4ca394632bedf05a (patch)
treef56340c0c944a37ee93a1e78e9505224ad7274f3 /test/ruby/test_enum.rb
parentd1a33d8ec514e24cbda8c62ab529b3920f0f97f4 (diff)
merge revision(s) ff41663403d3eb76d95f465cb94e14d2faaa04d1: [Backport #16354]
Fix memory corruption in Enumerable#reverse_each [ruby-dev:50867] [Bug #16354] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_enum.rb')
-rw-r--r--test/ruby/test_enum.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index c56e280e06..568fa0ea8d 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -730,6 +730,19 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal([2,1,3,2,1], @obj.reverse_each.to_a)
end
+ def test_reverse_each_memory_corruption
+ bug16354 = '[ruby-dev:50867]'
+ assert_normal_exit %q{
+ size = 1000
+ (0...size).reverse_each do |i|
+ i.inspect
+ ObjectSpace.each_object(Array) do |a|
+ a.clear if a.length == size
+ end
+ end
+ }, bug16354
+ end
+
def test_chunk
e = [].chunk {|elt| true }
assert_equal([], e.to_a)