diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-27 08:27:46 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-27 08:27:46 +0000 |
commit | 1c8500b3d1a327ff4e56af3c9ed9164130becc74 (patch) | |
tree | 74afc2d5843879ded6824b009bc2bbfbae288b30 /process.c | |
parent | 322b26795583a0b854e7b195e7f766bd479c0404 (diff) |
merge revision(s) 46075: [Backport #9856]
* process.c (proc_getgroups, proc_setgroups): use ALLOCV_N
[Bug #9856]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@46581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -5548,7 +5548,7 @@ maxgroups(void) static VALUE proc_getgroups(VALUE obj) { - VALUE ary; + VALUE ary, tmp; int i, ngroups; rb_gid_t *groups; @@ -5556,7 +5556,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) @@ -5566,6 +5566,8 @@ proc_getgroups(VALUE obj) for (i = 0; i < ngroups; i++) rb_ary_push(ary, GIDT2NUM(groups[i])); + ALLOCV_END(tmp); + return ary; } #else @@ -5592,6 +5594,7 @@ proc_setgroups(VALUE obj, VALUE ary) { int ngroups, i; rb_gid_t *groups; + VALUE tmp; PREPARE_GETGRNAM; Check_Type(ary, T_ARRAY); @@ -5600,7 +5603,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_PTR(ary)[i]; @@ -5612,6 +5615,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 |