mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/stringio/stringio.c (strio_write): insufficiently filled string
being extended when overwriting. [ruby-core:03836] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
37eb7502db
commit
af7418e5c4
3 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Nov 29 16:06:04 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/stringio/stringio.c (strio_write): insufficiently filled string
|
||||||
|
being extended when overwriting. [ruby-core:03836]
|
||||||
|
|
||||||
Mon Nov 29 15:22:28 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Nov 29 15:22:28 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* test/io/nonblock/test_flush.rb: abandon tests when io/nonblock is
|
* test/io/nonblock/test_flush.rb: abandon tests when io/nonblock is
|
||||||
|
|
|
@ -794,7 +794,7 @@ strio_write(self, str)
|
||||||
else {
|
else {
|
||||||
if (ptr->pos + len > olen) {
|
if (ptr->pos + len > olen) {
|
||||||
rb_str_resize(ptr->string, ptr->pos + len);
|
rb_str_resize(ptr->string, ptr->pos + len);
|
||||||
MEMZERO(RSTRING(ptr->string)->ptr + olen, char, ptr->pos - olen);
|
MEMZERO(RSTRING(ptr->string)->ptr + olen, char, ptr->pos + len - olen);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_str_modify(ptr->string);
|
rb_str_modify(ptr->string);
|
||||||
|
|
|
@ -30,4 +30,14 @@ class TestStringIO < Test::Unit::TestCase
|
||||||
io.print "last"
|
io.print "last"
|
||||||
assert_equal("\0" * n + "last", io.string)
|
assert_equal("\0" * n + "last", io.string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_overwrite # [ruby-core:03836]
|
||||||
|
stringio = StringIO.new
|
||||||
|
responses = ['', 'just another ruby', 'hacker']
|
||||||
|
responses.each do |resp|
|
||||||
|
stringio.puts(resp)
|
||||||
|
stringio.rewind
|
||||||
|
end
|
||||||
|
assert_equal("hacker\nother ruby\n", stringio.string)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue