summaryrefslogtreecommitdiff
path: root/lib/group-member.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-04-06 17:45:33 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2021-04-06 17:51:35 -0700
commit7e90795b4061e4d023c8ab4937d988dbbdbf9d15 (patch)
treee2f9df9a4c45bc1abb5b0499ade8e4946589b3bb /lib/group-member.c
parent4392cab3a01e2df101f3fd269c5b17aa969d0669 (diff)
downloadgnulib-7e90795b4061e4d023c8ab4937d988dbbdbf9d15.tar.gz
group-member: minor tweak to omit a *
* lib/group-member.c: Include intprops.h. (get_group_info): Use INT_MULTIPLY_WRAPV instead of xalloc_oversized (which does a multiplication) followed by the same multiplication. The code was OK as-is; this is just conceptual simplification, possible now that we have xalloc_count_t. * modules/group-member: Depend on intprops.
Diffstat (limited to 'lib/group-member.c')
-rw-r--r--lib/group-member.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/group-member.c b/lib/group-member.c
index 52159016ea..17bee831b4 100644
--- a/lib/group-member.c
+++ b/lib/group-member.c
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <stdlib.h>
+#include "intprops.h"
#include "xalloc-oversized.h"
/* Most processes have no more than this many groups, and for these
@@ -53,10 +54,11 @@ get_group_info (struct group_info *gi)
if (n_groups < 0)
{
int n_group_slots = getgroups (0, NULL);
+ xalloc_count_t nbytes;
if (0 <= n_group_slots
- && ! xalloc_oversized (n_group_slots, sizeof *gi->group))
+ && ! INT_MULTIPLY_WRAPV (n_group_slots, sizeof *gi->group, &nbytes))
{
- gi->group = malloc (n_group_slots * sizeof *gi->group);
+ gi->group = malloc (nbytes);
if (gi->group)
n_groups = getgroups (n_group_slots, gi->group);
}