1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-10-29 00:43:34 +00:00
parent 7b835184d7
commit 85195203f4
2 changed files with 5 additions and 1 deletions

2
io.c
View file

@ -1590,7 +1590,7 @@ io_fwritev(int argc, VALUE *argv, rb_io_t *fptr)
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)

View file

@ -1270,6 +1270,10 @@ class TestIO < Test::Unit::TestCase
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