Revision: 4342 http://trac.macosforge.org/projects/ruby/changeset/4342 Author: martinlagardette@apple.com Date: 2010-07-09 18:08:40 -0700 (Fri, 09 Jul 2010) Log Message: ----------- Fixes `IO#gets` by check NULL-ness *AND* emptyness of buffer - Fixes #754 Modified Paths: -------------- MacRuby/trunk/io.c Modified: MacRuby/trunk/io.c =================================================================== --- MacRuby/trunk/io.c 2010-07-09 21:19:34 UTC (rev 4341) +++ MacRuby/trunk/io.c 2010-07-10 01:08:40 UTC (rev 4342) @@ -460,13 +460,13 @@ if (length == 0) { return INT2FIX(0); } - + ssize_t code = write(io_struct->write_fd, buffer, length); if (code == -1) { rb_sys_fail("write() failed"); } - if (io_struct->buf != NULL) { + if (io_struct->buf != NULL && CFDataGetLength(io_struct->buf) > 0) { if (length > CFDataGetLength(io_struct->buf) - io_struct->buf_offset) { CFDataIncreaseLength(io_struct->buf, length); }