[前][次][番号順一覧][スレッド一覧]

ruby-changes:15644

From: akr <ko1@a...>
Date: Fri, 30 Apr 2010 12:06:59 +0900 (JST)
Subject: [ruby-changes:15644] Ruby:r27560 (trunk): * file.c (file_expand_path): call rb_str_set_len before BUFCHECK to

akr	2010-04-30 12:06:43 +0900 (Fri, 30 Apr 2010)

  New Revision: 27560

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27560

  Log:
    * file.c (file_expand_path): call rb_str_set_len before BUFCHECK to
      prevent rb_str_resize in BUFCHECK discard the content.

  Modified files:
    trunk/ChangeLog
    trunk/file.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27559)
+++ ChangeLog	(revision 27560)
@@ -1,3 +1,8 @@
+Fri Apr 30 12:05:20 2010  Tanaka Akira  <akr@f...>
+
+	* file.c (file_expand_path): call rb_str_set_len before BUFCHECK to
+	  prevent rb_str_resize in BUFCHECK discard the content.
+
 Fri Apr 30 11:48:31 2010  Marc-Andre Lafortune  <ruby-core@m...>
 
 	* string.c (rb_str_sub_bang): String#sub! now raises an error when
Index: file.c
===================================================================
--- file.c	(revision 27559)
+++ file.c	(revision 27560)
@@ -2858,10 +2858,12 @@
     if (p > buf && p[-1] == '/')
 	--p;
     else {
+	rb_str_set_len(result, p-buf);
 	BUFCHECK(bdiff + 1 >= buflen);
 	*p = '/';
     }
 
+    rb_str_set_len(result, p-buf+1);
     BUFCHECK(bdiff + 1 >= buflen);
     p[1] = 0;
     root = skipprefix(buf);
@@ -2925,6 +2927,7 @@
 #endif
 	    if (s > b) {
 		long rootdiff = root - buf;
+		rb_str_set_len(result, p-buf+1);
 		BUFCHECK(bdiff + (s-b+1) >= buflen);
 		root = buf + rootdiff;
 		memcpy(++p, b, s-b);
@@ -2955,6 +2958,7 @@
 	    }
 	}
 #endif
+	rb_str_set_len(result, p-buf+1);
 	BUFCHECK(bdiff + (s-b) >= buflen);
 	memcpy(++p, b, s-b);
 	p += s-b;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]