From b46b1e3f5a7ec5d72b9597f387e0eee802d4ab63 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 3 Sep 2014 07:56:09 +0000 Subject: object.c: fix memory leak * object.c (rb_obj_copy_ivar): allocate no memory for empty instance variables. [ruby-core:64700] [Bug #10191] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_object.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/ruby/test_object.rb') diff --git a/test/ruby/test_object.rb b/test/ruby/test_object.rb index 4573dc859e..e79913ead0 100644 --- a/test/ruby/test_object.rb +++ b/test/ruby/test_object.rb @@ -811,4 +811,14 @@ class TestObject < Test::Unit::TestCase assert_raise_with_message(TypeError, "can't convert Array into Integer") {Integer([42])} assert_raise_with_message(TypeError, 'no implicit conversion of Array into Integer') {[].first([42])} end + + def test_copied_ivar_memory_leak + bug10191 = '[ruby-core:64700] [Bug #10191]' + assert_no_memory_leak([], <<-"end;", <<-"end;", bug10191, rss: true) + def (a = Object.new).set; @v = nil; end + num = 500_000 + end; + num.times {a.clone.set} + end; + end end -- cgit v1.2.3