summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--test/ruby/test_const.rb8
-rw-r--r--variable.c2
-rw-r--r--version.h2
4 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e8dcfa5566..80ecd65154 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu Mar 20 21:13:18 2014 Eric Wong <e@80x24.org>
+
+ * variable.c (rb_const_set): delete existing entry on redefinition
+ [Bug #9645]
+ * test/ruby/test_const.rb (test_redefinition): test for leak
+
Thu Mar 20 20:44:17 2014 Kazuki Tsujimoto <kazuki@callcc.net>
* test/fiddle/test_c_struct_entry.rb,
diff --git a/test/ruby/test_const.rb b/test/ruby/test_const.rb
index dab45b7e08..c4a4d93249 100644
--- a/test/ruby/test_const.rb
+++ b/test/ruby/test_const.rb
@@ -1,5 +1,6 @@
# -*- coding: us-ascii -*-
require 'test/unit'
+require_relative 'envutil'
class TestConst < Test::Unit::TestCase
TEST1 = 1
@@ -54,5 +55,12 @@ class TestConst < Test::Unit::TestCase
#{__FILE__}:#{__LINE__-1}: warning: already initialized constant #{c}::X
#{__FILE__}:#{__LINE__-3}: warning: previous definition of X was here
WARNING
+ code = <<-PRE
+olderr = $stderr.dup
+$stderr.reopen(File::NULL, "wb")
+350000.times { FOO = :BAR }
+$stderr.reopen(olderr)
+PRE
+ assert_no_memory_leak([], '', code, 'redefined constant')
end
end
diff --git a/variable.c b/variable.c
index 79e00bef79..0c2f8e5841 100644
--- a/variable.c
+++ b/variable.c
@@ -2183,6 +2183,8 @@ rb_const_set(VALUE klass, ID id, VALUE val)
rb_compile_warn(RSTRING_PTR(ce->file), ce->line,
"previous definition of %"PRIsVALUE" was here", name);
}
+ st_delete(RCLASS_CONST_TBL(klass), &id, 0);
+ xfree(ce);
}
}
}
diff --git a/version.h b/version.h
index a14405c2e3..4b7457db83 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2014-03-20"
-#define RUBY_PATCHLEVEL 460
+#define RUBY_PATCHLEVEL 461
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 3