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

ruby-changes:47178

From: nagachika <ko1@a...>
Date: Mon, 10 Jul 2017 04:02:42 +0900 (JST)
Subject: [ruby-changes:47178] nagachika:r59293 (ruby_2_4): merge revision(s) 58658: [Backport #13554]

nagachika	2017-07-10 04:02:35 +0900 (Mon, 10 Jul 2017)

  New Revision: 59293

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59293

  Log:
    merge revision(s) 58658: [Backport #13554]
    
    process.c: temporary string for buffer
    
    * process.c (obj2uid, obj2gid): use temporary string as the buffer
      instead of `rb_alloc_tmp_buffer`, which is `NODE_ALLOCA` since
      r51492.  [ruby-core:81084] [Bug #13554]

  Modified directories:
    branches/ruby_2_4/
  Modified files:
    branches/ruby_2_4/process.c
    branches/ruby_2_4/version.h
Index: ruby_2_4/process.c
===================================================================
--- ruby_2_4/process.c	(revision 59292)
+++ ruby_2_4/process.c	(revision 59293)
@@ -172,7 +172,7 @@ static void check_gid_switch(void); https://github.com/ruby/ruby/blob/trunk/ruby_2_4/process.c#L172
 #   define PREPARE_GETPWNAM \
     VALUE getpw_buf = 0
 #   define FINISH_GETPWNAM \
-    ALLOCV_END(getpw_buf)
+    (getpw_buf ? (void)rb_str_resize(getpw_buf, 0) : (void)0)
 #   define OBJ2UID1(id) obj2uid((id), &getpw_buf)
 #   define OBJ2UID(id) obj2uid0(id)
 static rb_uid_t obj2uid(VALUE id, VALUE *getpw_buf);
@@ -214,7 +214,7 @@ static rb_uid_t obj2uid(VALUE id); https://github.com/ruby/ruby/blob/trunk/ruby_2_4/process.c#L214
 #   define PREPARE_GETGRNAM \
     VALUE getgr_buf = 0
 #   define FINISH_GETGRNAM \
-    ALLOCV_END(getgr_buf)
+    (getgr_buf ? (void)rb_str_resize(getgr_buf, 0) : (void)0)
 #   define OBJ2GID1(id) obj2gid((id), &getgr_buf)
 #   define OBJ2GID(id) obj2gid0(id)
 static rb_gid_t obj2gid(VALUE id, VALUE *getgr_buf);
@@ -5033,18 +5033,17 @@ obj2uid(VALUE id https://github.com/ruby/ruby/blob/trunk/ruby_2_4/process.c#L5033
 	if (!*getpw_tmp) {
 	    getpw_buf_len = GETPW_R_SIZE_INIT;
 	    if (getpw_buf_len < 0) getpw_buf_len = GETPW_R_SIZE_DEFAULT;
-	    getpw_buf = rb_alloc_tmp_buffer(getpw_tmp, getpw_buf_len);
-	}
-	else {
-	    getpw_buf = RSTRING_PTR(*getpw_tmp);
-	    getpw_buf_len = rb_str_capacity(*getpw_tmp);
+	    *getpw_tmp = rb_str_tmp_new(getpw_buf_len);
 	}
+	getpw_buf = RSTRING_PTR(*getpw_tmp);
+	getpw_buf_len = rb_str_capacity(*getpw_tmp);
+	rb_str_set_len(*getpw_tmp, getpw_buf_len);
 	errno = ERANGE;
 	/* gepwnam_r() on MacOS X doesn't set errno if buffer size is insufficient */
 	while (getpwnam_r(usrname, &pwbuf, getpw_buf, getpw_buf_len, &pwptr)) {
 	    int e = errno;
 	    if (e != ERANGE || getpw_buf_len >= GETPW_R_SIZE_LIMIT) {
-		rb_free_tmp_buffer(getpw_tmp);
+		rb_str_resize(*getpw_tmp, 0);
 		rb_syserr_fail(e, "getpwnam_r");
 	    }
 	    rb_str_modify_expand(*getpw_tmp, getpw_buf_len);
@@ -5112,18 +5111,17 @@ obj2gid(VALUE id https://github.com/ruby/ruby/blob/trunk/ruby_2_4/process.c#L5111
 	if (!*getgr_tmp) {
 	    getgr_buf_len = GETGR_R_SIZE_INIT;
 	    if (getgr_buf_len < 0) getgr_buf_len = GETGR_R_SIZE_DEFAULT;
-	    getgr_buf = rb_alloc_tmp_buffer(getgr_tmp, getgr_buf_len);
-	}
-	else {
-	    getgr_buf = RSTRING_PTR(*getgr_tmp);
-	    getgr_buf_len = rb_str_capacity(*getgr_tmp);
+	    *getgr_tmp = rb_str_tmp_new(getgr_buf_len);
 	}
+	getgr_buf = RSTRING_PTR(*getgr_tmp);
+	getgr_buf_len = rb_str_capacity(*getgr_tmp);
+	rb_str_set_len(*getgr_tmp, getgr_buf_len);
 	errno = ERANGE;
 	/* gegrnam_r() on MacOS X doesn't set errno if buffer size is insufficient */
 	while (getgrnam_r(grpname, &grbuf, getgr_buf, getgr_buf_len, &grptr)) {
 	    int e = errno;
 	    if (e != ERANGE || getgr_buf_len >= GETGR_R_SIZE_LIMIT) {
-		rb_free_tmp_buffer(getgr_tmp);
+		rb_str_resize(*getgr_tmp, 0);
 		rb_syserr_fail(e, "getgrnam_r");
 	    }
 	    rb_str_modify_expand(*getgr_tmp, getgr_buf_len);
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 59292)
+++ ruby_2_4/version.h	(revision 59293)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.2"
-#define RUBY_RELEASE_DATE "2017-07-08"
-#define RUBY_PATCHLEVEL 133
+#define RUBY_RELEASE_DATE "2017-07-10"
+#define RUBY_PATCHLEVEL 134
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 7
-#define RUBY_RELEASE_DAY 8
+#define RUBY_RELEASE_DAY 10
 
 #include "ruby/version.h"
 
Index: ruby_2_4
===================================================================
--- ruby_2_4	(revision 59292)
+++ ruby_2_4	(revision 59293)

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r58658

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

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