]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/gshadow.c: build_list(): Fix REALLOC() nmemb calculation
authorAlejandro Colomar <alx@kernel.org>
Mon, 13 May 2024 02:07:51 +0000 (04:07 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 2 Jul 2024 02:40:11 +0000 (21:40 -0500)
Fixes: efbbcade43ff ("Use safer allocation macros")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/gshadow.c

index 407794958f9c9e54d30d8590fb500e170006337e..b551c4cf19f00eb5e067a5db51e215f704b0aa50 100644 (file)
@@ -37,8 +37,7 @@ static /*@null@*/char **build_list (char *s, char **list[], size_t * nlist)
        size_t nelem = *nlist, size;
 
        while (s != NULL && *s != '\0') {
-               size = (nelem + 1) * sizeof (ptr);
-               ptr = REALLOC(*list, size, char *);
+               ptr = REALLOC(*list, nelem + 1, char *);
                if (ptr == NULL)
                        return NULL;
 
@@ -48,8 +47,7 @@ static /*@null@*/char **build_list (char *s, char **list[], size_t * nlist)
                *nlist = nelem;
        }
 
-       size = (nelem + 1) * sizeof (ptr);
-       ptr = REALLOC(*list, size, char *);
+       ptr = REALLOC(*list, nelem + 1, char *);
        if (ptr == NULL)
                return NULL;