diff --git a/ChangeLog b/ChangeLog index 2b335692..7b464e7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-06-13 Nicolas François + + * src/groups.c: sys_ngroups is only used when HAVE_GETGROUPS is + defined. + 2008-06-13 Nicolas François * src/faillog.c: Ignore return value of time() when use with a diff --git a/src/groups.c b/src/groups.c index df9650c8..f7bbe5cd 100644 --- a/src/groups.c +++ b/src/groups.c @@ -106,9 +106,8 @@ static void print_groups (const char *member) */ int main (int argc, char **argv) { - long sys_ngroups; - #ifdef HAVE_GETGROUPS + long sys_ngroups; int ngroups; GETGROUPS_T *groups; int pri_grp; /* TODO: should be GETGROUPS_T */ @@ -118,9 +117,9 @@ int main (int argc, char **argv) char *getlogin (); #endif - sys_ngroups = sysconf (_SC_NGROUPS_MAX); #ifdef HAVE_GETGROUPS - groups = (GETGROUPS_T *) malloc (sys_ngroups * sizeof (GETGROUPS_T)); + sys_ngroups = sysconf (_SC_NGROUPS_MAX); + groups = (GETGROUPS_T *) malloc (sizeof (GETGROUPS_T) * sys_ngroups); #endif (void) setlocale (LC_ALL, ""); (void) bindtextdomain (PACKAGE, LOCALEDIR);