From d450229a277d32136e9d2b30408b519ee81586be Mon Sep 17 00:00:00 2001 From: normal Date: Sat, 24 May 2014 07:22:54 +0000 Subject: process.c (proc_getgroups, proc_setgroups): use ALLOCV_N * process.c (proc_getgroups, proc_setgroups): use ALLOCV_N [Bug #9856] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- process.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'process.c') diff --git a/process.c b/process.c index ace15b1c71..d4977ebff5 100644 --- a/process.c +++ b/process.c @@ -5547,7 +5547,7 @@ maxgroups(void) static VALUE proc_getgroups(VALUE obj) { - VALUE ary; + VALUE ary, tmp; int i, ngroups; rb_gid_t *groups; @@ -5555,7 +5555,7 @@ proc_getgroups(VALUE obj) if (ngroups == -1) rb_sys_fail(0); - groups = ALLOCA_N(rb_gid_t, ngroups); + groups = ALLOCV_N(rb_gid_t, tmp, ngroups); ngroups = getgroups(ngroups, groups); if (ngroups == -1) @@ -5565,6 +5565,8 @@ proc_getgroups(VALUE obj) for (i = 0; i < ngroups; i++) rb_ary_push(ary, GIDT2NUM(groups[i])); + ALLOCV_END(tmp); + return ary; } #else @@ -5591,6 +5593,7 @@ proc_setgroups(VALUE obj, VALUE ary) { int ngroups, i; rb_gid_t *groups; + VALUE tmp; PREPARE_GETGRNAM; Check_Type(ary, T_ARRAY); @@ -5599,7 +5602,7 @@ proc_setgroups(VALUE obj, VALUE ary) if (ngroups > maxgroups()) rb_raise(rb_eArgError, "too many groups, %d max", maxgroups()); - groups = ALLOCA_N(rb_gid_t, ngroups); + groups = ALLOCV_N(rb_gid_t, tmp, ngroups); for (i = 0; i < ngroups; i++) { VALUE g = RARRAY_AREF(ary, i); @@ -5611,6 +5614,8 @@ proc_setgroups(VALUE obj, VALUE ary) if (setgroups(ngroups, groups) == -1) /* ngroups <= maxgroups */ rb_sys_fail(0); + ALLOCV_END(tmp); + return proc_getgroups(obj); } #else -- cgit v1.2.3