From: Jim Cromie Date: Fri, 23 Dec 2005 13:24:29 +0000 (-0700) Subject: Re: [perl #37907] Perl_magic_get reqires ridiculous amounts of stackmemory X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=57d7c65eded7a5f963c5ce38ee196978a06e35df;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #37907] Perl_magic_get reqires ridiculous amounts of stackmemory Message-ID: <43AC5CFD.3060200@gmail.com> Includes a change in variable names from "j" to "num_groups". p4raw-id: //depot/perl@26480 --- diff --git a/mg.c b/mg.c index 0722f44..5072a8f 100644 --- a/mg.c +++ b/mg.c @@ -1006,10 +1006,14 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg) add_groups: #ifdef HAS_GETGROUPS { - Groups_t gary[NGROUPS]; - I32 j = getgroups(NGROUPS,gary); - while (--j >= 0) - Perl_sv_catpvf(aTHX_ sv, " %"Gid_t_f, (long unsigned int)gary[j]); + Groups_t *gary = NULL; + I32 num_groups = getgroups(0, gary); + Newx(gary, num_groups, Groups_t); + num_groups = getgroups(num_groups, gary); + while (--num_groups >= 0) + Perl_sv_catpvf(aTHX_ sv, " %"Gid_t_f, + (long unsigned int)gary[num_groups]); + Safefree(gary); } #endif (void)SvIOK_on(sv); /* what a wonderful hack! */