mgetgroups: remove dependency on realloc-gnu
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 14 Oct 2013 06:08:42 +0000 (23:08 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 14 Oct 2013 06:09:02 +0000 (23:09 -0700)
The dependency violates the comment in realloc-gnu, which
says that tests can't depend on realloc-gnu; some tests depend
on mgetgroups, so mgetgroups can't depend on realloc-gnu.
Problem reported by Daniel Richard G. in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-10/msg00056.html>.
* lib/mgetgroups.c (mgetgroups): Don't call realloc (NULL, 0).
* modules/mgetgroups (Depends-on): Depend on realloc-posix,
not realloc-gnu.

ChangeLog
lib/mgetgroups.c
modules/mgetgroups

index e3e514c..ad2b141 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2013-10-13  Paul Eggert  <eggert@cs.ucla.edu>
+
+       mgetgroups: remove dependency on realloc-gnu
+       The dependency violates the comment in realloc-gnu, which
+       says that tests can't depend on realloc-gnu; some tests depend
+       on mgetgroups, so mgetgroups can't depend on realloc-gnu.
+       Problem reported by Daniel Richard G. in
+       <http://lists.gnu.org/archive/html/bug-gnulib/2013-10/msg00056.html>.
+       * lib/mgetgroups.c (mgetgroups): Don't call realloc (NULL, 0).
+       * modules/mgetgroups (Depends-on): Depend on realloc-posix,
+       not realloc-gnu.
+
 2013-10-12  Paul Eggert  <eggert@cs.ucla.edu>
 
        regex-tests: port to HP-UX 11.11
index 2d82f45..846662b 100644 (file)
@@ -133,7 +133,7 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups)
       return -1;
     }
 
-  if (!username && gid != (gid_t) -1)
+  if (max_n_groups == 0 || (!username && gid != (gid_t) -1))
     max_n_groups++;
   g = realloc_groupbuf (NULL, max_n_groups);
   if (g == NULL)
index 76eee01..f401cdf 100644 (file)
@@ -9,7 +9,7 @@ m4/mgetgroups.m4
 Depends-on:
 getgroups
 getugroups
-realloc-gnu
+realloc-posix
 xalloc-oversized
 
 configure.ac: