[前][次][番号順一覧][スレッド一覧]

ruby-changes:48420

From: nobu <ko1@a...>
Date: Sun, 29 Oct 2017 09:43:38 +0900 (JST)
Subject: [ruby-changes:48420] nobu:r60534 (trunk): io.c: convert to string at writev

nobu	2017-10-29 09:43:34 +0900 (Sun, 29 Oct 2017)

  New Revision: 60534

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60534

  Log:
    io.c: convert to string at writev
    
    * io.c (io_fwritev): needs conversion to string before accessing
      the content, as well as single argument case, not to segfault.
      [Feature #9323]

  Modified files:
    trunk/io.c
    trunk/test/ruby/test_io.rb
Index: test/ruby/test_io.rb
===================================================================
--- test/ruby/test_io.rb	(revision 60533)
+++ test/ruby/test_io.rb	(revision 60534)
@@ -1270,6 +1270,10 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L1270
     end
   end
 
+  def test_write_with_multiple_nonstring_arguments
+    assert_in_out_err([], "STDOUT.write(:foo, :bar)", ["foobar"])
+  end
+
   def test_write_non_writable
     with_pipe do |r, w|
       assert_raise(IOError) do
Index: io.c
===================================================================
--- io.c	(revision 60533)
+++ io.c	(revision 60534)
@@ -1590,7 +1590,7 @@ io_fwritev(int argc, VALUE *argv, rb_io_ https://github.com/ruby/ruby/blob/trunk/io.c#L1590
     tmp_array = ALLOCV_N(VALUE, v2, argc);
 
     for (i = 0; i < argc; i++) {
-	str = argv[i];
+	str = rb_obj_as_string(argv[i]);
 	converted = 0;
 	str = do_writeconv(str, fptr, &converted);
 	if (converted)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]