summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-24 07:22:54 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-24 07:22:54 +0000
commitd450229a277d32136e9d2b30408b519ee81586be (patch)
tree10ebc98cd306d78c552c1cf443e3dd47b1cd74df /process.c
parent36f3ee6dc876377cdef28da601dfe2f4e45e0f39 (diff)
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
Diffstat (limited to 'process.c')
-rw-r--r--process.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/process.c b/process.c
index ace15b1..d4977eb 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