Revision: 4155 http://trac.macosforge.org/projects/ruby/changeset/4155 Author: martinlagardette@apple.com Date: 2010-05-25 18:44:37 -0700 (Tue, 25 May 2010) Log Message: ----------- Truncate buffer passed to io.read() - Fixes #719 Modified Paths: -------------- MacRuby/trunk/io.c Modified: MacRuby/trunk/io.c =================================================================== --- MacRuby/trunk/io.c 2010-05-26 01:15:56 UTC (rev 4154) +++ MacRuby/trunk/io.c 2010-05-26 01:44:37 UTC (rev 4155) @@ -1123,6 +1123,11 @@ outbuf = rb_bstr_new(); outbuf_created = true; } + else { + StringValue(outbuf); + outbuf = rb_str_bstr(outbuf); + rb_str_set_len(outbuf, 0); + } if (NIL_P(len)) { rb_io_read_all(io_struct, outbuf); @@ -1144,7 +1149,6 @@ rb_raise(rb_eArgError, "given size `%ld' is too big", size); } - outbuf = rb_str_bstr(outbuf); rb_bstr_resize(outbuf, size); uint8_t *bytes = rb_bstr_bytes(outbuf);