]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Use reallocarrayf() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Sat, 4 Feb 2023 21:52:13 +0000 (22:52 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 24 Feb 2023 02:28:43 +0000 (20:28 -0600)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
libmisc/addgrps.c

index 32f8af012eccd0e100552e5346553b357f1ef417..688e3e51f5322d31d30ee8c54ade41c61a59bfee 100644 (file)
@@ -29,7 +29,7 @@
  */
 int add_groups (const char *list)
 {
-       GETGROUPS_T *grouplist, *tmp;
+       GETGROUPS_T *grouplist;
        size_t i;
        int ngroups;
        bool added;
@@ -88,14 +88,12 @@ int add_groups (const char *list)
                        fputs (_("Warning: too many groups\n"), shadow_logfd);
                        break;
                }
-               tmp = (gid_t *) reallocarray (grouplist, (size_t)ngroups + 1, sizeof (GETGROUPS_T));
-               if (NULL == tmp) {
-                       free (grouplist);
+               grouplist = (gid_t *) reallocarrayf (grouplist, (size_t)ngroups + 1, sizeof (GETGROUPS_T));
+               if (grouplist == NULL) {
                        return -1;
                }
-               tmp[ngroups] = grp->gr_gid;
+               grouplist[ngroups] = grp->gr_gid;
                ngroups++;
-               grouplist = tmp;
                added = true;
        }