lib/gshadow.c: build_list(): Fix REALLOC() nmemb calculation
Fixes: efbbcade43 ("Use safer allocation macros")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
056f1d03ee
commit
c287317075
+2
-4
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user