about summary refs log tree commit homepage
path: root/ext/kgio/read_write.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/kgio/read_write.c')
-rw-r--r--ext/kgio/read_write.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/ext/kgio/read_write.c b/ext/kgio/read_write.c
index 330c2f4..7df7070 100644
--- a/ext/kgio/read_write.c
+++ b/ext/kgio/read_write.c
@@ -68,6 +68,7 @@ static void prepare_read(struct io_args *a, int argc, VALUE *argv, VALUE io)
                 a->buf = rb_str_new(NULL, a->len);
         } else {
                 StringValue(a->buf);
+                rb_str_modify(a->buf);
                 rb_str_resize(a->buf, a->len);
         }
         a->ptr = RSTRING_PTR(a->buf);
@@ -86,6 +87,7 @@ static int read_check(struct io_args *a, long n, const char *msg, int io_wait)
                                 (void)kgio_call_wait_readable(a->io);
 
                                 /* buf may be modified in other thread/fiber */
+                                rb_str_modify(a->buf);
                                 rb_str_resize(a->buf, a->len);
                                 a->ptr = RSTRING_PTR(a->buf);
                                 return -1;