From 4b9a21cdd6881325836ec54d1daca47c9ce4fa02 Mon Sep 17 00:00:00 2001 From: normal Date: Mon, 30 Jan 2017 22:03:57 +0000 Subject: io.c (rb_io_syswrite): avoid leaving garbage after write As with IO#write, IO#syswrite also generates garbage which can be harmful in hand-coded read-write loops. * io.c (swrite_arg, swrite_do, swrite_end): new (rb_io_syswrite): use new functions to cleanup garbage [ruby-core:78898] [Bug #13085] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'test/ruby') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index c501edd0ab..3cc410881c 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -3512,11 +3512,13 @@ __END__ with_pipe do |r, w| before = ObjectSpace.count_objects(res)[:T_STRING] n = w.write(buf) + s = w.syswrite(buf) after = ObjectSpace.count_objects(res)[:T_STRING] assert_equal before, after, 'no strings left over after write [ruby-core:78898] [Bug #13085]' assert_not_predicate buf, :frozen?, 'no inadvertant freeze' - assert_equal buf.bytesize, n, 'wrote expected size' + assert_equal buf.bytesize, n, 'write wrote expected size' + assert_equal s, n, 'syswrite wrote expected size' end end end -- cgit v1.2.3