diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-05 01:51:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-07-05 01:51:51 +0000 |
commit | 481292190fa34536d510e2140647d07339a4df72 (patch) | |
tree | 0c89629117dfe951d31d775d1cfe26ad60c8f44d /test | |
parent | 033e8e5b61fa4f800900b5d7487c575014b3761b (diff) | |
download | ruby-481292190fa34536d510e2140647d07339a4df72.tar.gz |
array.c: fix memory leak
* array.c (rb_ary_sort_bang): the original array may not be
embedded even if a substitution array is embedded, as it is
embedded when the original array is short enough but not
embedded. [ruby-dev:49166] [Bug #11332]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_array.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index f6d0d3d434..51caf8fa37 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1445,6 +1445,16 @@ class TestArray < Test::Unit::TestCase assert_equal(orig, ary, "must not be modified once frozen") end + def test_short_heap_array_sort_bang_memory_leak + bug11332 = '[ruby-dev:49166] [Bug #11332]' + assert_no_memory_leak([], <<-PREP, <<-TEST, bug11332, limit: 1.20) + def t; ary = [*1..5]; ary.pop(2); ary.sort!; end + 1.times {t} + PREP + 500000.times {t} + TEST + end + def test_to_a a = @cls[ 1, 2, 3 ] a_id = a.__id__ |