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
This commit is contained in:
normal 2014-05-24 07:22:54 +00:00
Родитель 36f3ee6dc8
Коммит d450229a27
2 изменённых файлов: 13 добавлений и 3 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sat May 24 16:20:59 2014 Eric Wong <e@80x24.org>
* process.c (proc_getgroups, proc_setgroups): use ALLOCV_N
[Bug #9856]
Sat May 24 15:49:39 2014 Tanaka Akira <akr@fsij.org> Sat May 24 15:49:39 2014 Tanaka Akira <akr@fsij.org>
* test/lib/minitest/unit.rb (parallelize_me!): Removed. * test/lib/minitest/unit.rb (parallelize_me!): Removed.

Просмотреть файл

@ -5547,7 +5547,7 @@ maxgroups(void)
static VALUE static VALUE
proc_getgroups(VALUE obj) proc_getgroups(VALUE obj)
{ {
VALUE ary; VALUE ary, tmp;
int i, ngroups; int i, ngroups;
rb_gid_t *groups; rb_gid_t *groups;
@ -5555,7 +5555,7 @@ proc_getgroups(VALUE obj)
if (ngroups == -1) if (ngroups == -1)
rb_sys_fail(0); rb_sys_fail(0);
groups = ALLOCA_N(rb_gid_t, ngroups); groups = ALLOCV_N(rb_gid_t, tmp, ngroups);
ngroups = getgroups(ngroups, groups); ngroups = getgroups(ngroups, groups);
if (ngroups == -1) if (ngroups == -1)
@ -5565,6 +5565,8 @@ proc_getgroups(VALUE obj)
for (i = 0; i < ngroups; i++) for (i = 0; i < ngroups; i++)
rb_ary_push(ary, GIDT2NUM(groups[i])); rb_ary_push(ary, GIDT2NUM(groups[i]));
ALLOCV_END(tmp);
return ary; return ary;
} }
#else #else
@ -5591,6 +5593,7 @@ proc_setgroups(VALUE obj, VALUE ary)
{ {
int ngroups, i; int ngroups, i;
rb_gid_t *groups; rb_gid_t *groups;
VALUE tmp;
PREPARE_GETGRNAM; PREPARE_GETGRNAM;
Check_Type(ary, T_ARRAY); Check_Type(ary, T_ARRAY);
@ -5599,7 +5602,7 @@ proc_setgroups(VALUE obj, VALUE ary)
if (ngroups > maxgroups()) if (ngroups > maxgroups())
rb_raise(rb_eArgError, "too many groups, %d max", 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++) { for (i = 0; i < ngroups; i++) {
VALUE g = RARRAY_AREF(ary, i); VALUE g = RARRAY_AREF(ary, i);
@ -5611,6 +5614,8 @@ proc_setgroups(VALUE obj, VALUE ary)
if (setgroups(ngroups, groups) == -1) /* ngroups <= maxgroups */ if (setgroups(ngroups, groups) == -1) /* ngroups <= maxgroups */
rb_sys_fail(0); rb_sys_fail(0);
ALLOCV_END(tmp);
return proc_getgroups(obj); return proc_getgroups(obj);
} }
#else #else