[macruby-changes] [2475] MacRuby/trunk/io.c

source_changes at macosforge.org source_changes at macosforge.org
Fri Sep 4 17:56:34 PDT 2009


Revision: 2475
          http://trac.macosforge.org/projects/ruby/changeset/2475
Author:   vincent.isambart at gmail.com
Date:     2009-09-04 17:56:32 -0700 (Fri, 04 Sep 2009)
Log Message:
-----------
fixed a bug in ungetc

Modified Paths:
--------------
    MacRuby/trunk/io.c

Modified: MacRuby/trunk/io.c
===================================================================
--- MacRuby/trunk/io.c	2009-09-04 21:19:19 UTC (rev 2474)
+++ MacRuby/trunk/io.c	2009-09-05 00:56:32 UTC (rev 2475)
@@ -1713,16 +1713,18 @@
     }
 
     rb_io_create_buf(io_struct);
-    UInt8 *data = CFDataGetMutableBytePtr(io_struct->buf);
 
     if (len <= io_struct->buf_offset) {
 	io_struct->buf_offset -= len;
+	UInt8 *data = CFDataGetMutableBytePtr(io_struct->buf);
 	memcpy(data + io_struct->buf_offset, bytes, len);
     }
     else {
 	const long n = len - io_struct->buf_offset;
 	CFDataIncreaseLength(io_struct->buf, n);
-	memmove(data + n, data, CFDataGetLength(io_struct->buf));
+	// CFDataGetMutableBytePtr must be called after CFDataIncreaseLength
+	UInt8 *data = CFDataGetMutableBytePtr(io_struct->buf);
+	memmove(data + n, data, CFDataGetLength(io_struct->buf) - n);
 	memcpy(data, bytes, len);
     }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090904/5a1fa22c/attachment.html>


More information about the macruby-changes mailing list