From c2873170759624014a963b988ef3f598999a008b Mon Sep 17 00:00:00 2001 From: Alejandro Colomar Date: Mon, 13 May 2024 04:07:51 +0200 Subject: [PATCH] lib/gshadow.c: build_list(): Fix REALLOC() nmemb calculation Fixes: efbbcade43ff ("Use safer allocation macros") Signed-off-by: Alejandro Colomar --- lib/gshadow.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/gshadow.c b/lib/gshadow.c index 40779495..b551c4cf 100644 --- a/lib/gshadow.c +++ b/lib/gshadow.c @@ -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;