Obviously, Perl_ingroup() is also using 256k of stack memory on Linux.
Steve Peters [Mon, 26 Dec 2005 03:51:24 +0000 (03:51 +0000)]
Adapt change #26480 to reduce memory usage here as well.
p4raw-link: @26480 on //depot/perl: 57d7c65eded7a5f963c5ce38ee196978a06e35df

p4raw-id: //depot/perl@26486

doio.c

diff --git a/doio.c b/doio.c
index 4015d17..4c913d8 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -1932,13 +1932,21 @@ Perl_ingroup(pTHX_ Gid_t testgid, bool effective)
 #define NGROUPS 32
 #endif
     {
-       Groups_t gary[NGROUPS];
+       Groups_t *gary = NULL;
        I32 anum;
+        bool rc = FALSE;
 
-       anum = getgroups(NGROUPS,gary);
+       anum = getgroups(0, gary);
+        Newx(gary, anum, Groups_t);
+        anum = getgroups(anum, gary);
        while (--anum >= 0)
-           if (gary[anum] == testgid)
-               return TRUE;
+           if (gary[anum] == testgid) {
+                rc = TRUE;
+                break;
+            }
+
+        Safefree(gary);
+        return rc;
     }
 #endif
     return FALSE;