From: Alejandro Colomar Date: Mon, 13 May 2024 02:07:51 +0000 (+0200) Subject: lib/gshadow.c: build_list(): Fix REALLOC() nmemb calculation X-Git-Tag: 4.17.0-rc1~189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2873170759624014a963b988ef3f598999a008b;p=thirdparty%2Fshadow.git lib/gshadow.c: build_list(): Fix REALLOC() nmemb calculation Fixes: efbbcade43ff ("Use safer allocation macros") Signed-off-by: Alejandro Colomar --- diff --git a/lib/gshadow.c b/lib/gshadow.c index 407794958..b551c4cf1 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;