summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-31 10:56:17 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-31 10:56:17 +0000
commit6d7cab3bd6db434f8299c1ef52aa62a92129f41b (patch)
tree1a904e48265886e4cae5eca58b0a71d581b0fdbc /io.c
parent67305e790df68b4009862e7a971fa7c075de5cea (diff)
merge revision(s) 66242: [Backport #15387]
io.c (io_write_nonblock): add RB_GC_GUARD, io_fflush may switch threads Since io_fflush may block on mutex or rb_io_wait_readable and switch threads, we need to ensure the `str' VALUE returned by `rb_obj_as_string` is visible to GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@66965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/io.c b/io.c
index 4440418d96..be5c0d2b27 100644
--- a/io.c
+++ b/io.c
@@ -2712,6 +2712,7 @@ io_write_nonblock(VALUE io, VALUE str, VALUE ex)
rb_io_set_nonblock(fptr);
n = write(fptr->fd, RSTRING_PTR(str), RSTRING_LEN(str));
+ RB_GC_GUARD(str);
if (n == -1) {
int e = errno;