Bug #10942 ยป 0001-stringio-avoid-STR_NOFREE-due-to-constant-string.patch
ext/stringio/stringio.c | ||
---|---|---|
ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE;
|
||
break;
|
||
case 0:
|
||
string = rb_enc_str_new("", 0, rb_default_external_encoding());
|
||
string = rb_enc_str_new(0, 0, rb_default_external_encoding());
|
||
ptr->flags = FMODE_READWRITE;
|
||
break;
|
||
}
|
test/stringio/test_stringio.rb | ||
---|---|---|
assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.each_line(0){} }
|
||
assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.each_line("a",0){} }
|
||
end
|
||
def test_no_leak_on_malloced_string
|
||
assert_no_memory_leak(%w(-rstringio), 'str = " " * 24',
|
||
'1000000.times { StringIO.new << str }',
|
||
'no leak on malloced string')
|
||
end
|
||
end
|
||
-
|