about summary refs log tree commit homepage
path: root/ext/kgio/read_write.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-05-05 13:24:36 -0700
committerEric Wong <normalperson@yhbt.net>2011-05-05 13:29:15 -0700
commit9c98bbd79f152fd72b257f9c37ca185587e56225 (patch)
tree4112448567043f78b832faeff484f903f013127d /ext/kgio/read_write.c
parentc821ebeb851807840f74c4cb4f1a10e691bf222a (diff)
downloadkgio-9c98bbd79f152fd72b257f9c37ca185587e56225.tar.gz
This is needed under Ruby trunk if the string is not actually
resized.
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;