]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(xgetgroups): Use xnmalloc, rather than xmalloc.
authorJim Meyering <jim@meyering.net>
Thu, 6 May 2004 14:43:31 +0000 (14:43 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 6 May 2004 14:43:31 +0000 (14:43 +0000)
Don't add `1' to the buffer size (it was to protect against malloc
implementations that fail to allocate a buffer of size zero).
That is no longer necessary, since we use a malloc wrapper
on such systems.

src/id.c

index db4883c8376ab7048356e4a354a4a9642e7c0b9a..0fec74fe2d656c081586f38b3b0f37e657991ade 100644 (file)
--- a/src/id.c
+++ b/src/id.c
@@ -261,8 +261,7 @@ xgetgroups (const char *username, gid_t gid, int *n_groups,
   else
     max_n_groups = getugroups (0, NULL, username, gid);
 
-  /* Add 1 just in case max_n_groups is zero.  */
-  g = xmalloc (max_n_groups * sizeof (GETGROUPS_T) + 1);
+  g = xnmalloc (max_n_groups, sizeof (GETGROUPS_T));
   if (username == 0)
     ng = getgroups (max_n_groups, g);
   else