This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
mg.c uses a fixed NGROUPS contant
[perl5.git] / mg.c
diff --git a/mg.c b/mg.c
index 05f8cd9..aaed62d 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -2667,11 +2667,19 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
        {
            const char *p = SvPV_const(sv, len);
             Groups_t *gary = NULL;
+#ifdef _SC_NGROUPS_MAX
+           int maxgrp = sysconf(_SC_NGROUPS_MAX);
+
+           if (maxgrp < 0)
+               maxgrp = NGROUPS;
+#else
+           int maxgrp = NGROUPS;
+#endif
 
             while (isSPACE(*p))
                 ++p;
             PL_egid = Atol(p);
-            for (i = 0; i < NGROUPS; ++i) {
+            for (i = 0; i < maxgrp; ++i) {
                 while (*p && !isSPACE(*p))
                     ++p;
                 while (isSPACE(*p))