mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
(xgetgroups): Use xnmalloc, rather than xmalloc.
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.
This commit is contained in:
1 parent
782b73c514
commit
76ef73f50a
1 file changed
+1
-2
@@ -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
|
||||
|
||||
Reference in new issue
Block a user