Bug #9645 ยป 0001-variable.c-avoid-memory-leak-on-const-redefinition.patch
test/ruby/test_const.rb | ||
---|---|---|
# -*- coding: us-ascii -*-
|
||
require 'test/unit'
|
||
require_relative 'envutil'
|
||
class TestConst < Test::Unit::TestCase
|
||
TEST1 = 1
|
||
... | ... | |
#{__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
|
variable.c | ||
---|---|---|
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);
|
||
}
|
||
}
|
||
}
|