From: Alejandro Colomar Date: Sun, 30 Jun 2024 21:55:56 +0000 (+0200) Subject: lib/gshadow.c: Use XREALLOC() instead of silently continuing on ENOMEM X-Git-Tag: 4.17.0-rc1~172 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4eed3e84a1488ffc93b4131a55ce84a9bba9a75d;p=thirdparty%2Fshadow.git lib/gshadow.c: Use XREALLOC() instead of silently continuing on ENOMEM We should do better, and correctly handle errors, since this is library code. However, I'm lazy right now, so let's die hard, and let us improve this later. Link: Reported-by: Serge Hallyn Signed-off-by: Alejandro Colomar --- diff --git a/lib/gshadow.c b/lib/gshadow.c index c26d8a3c5..042138882 100644 --- a/lib/gshadow.c +++ b/lib/gshadow.c @@ -19,6 +19,7 @@ #include "alloc/malloc.h" #include "alloc/realloc.h" +#include "alloc/x/xrealloc.h" #include "prototypes.h" #include "defines.h" @@ -38,20 +39,14 @@ static /*@null@*/char **build_list (char *s, char **list[], size_t * nlist) size_t nelem = *nlist, size; while (s != NULL && *s != '\0') { - ptr = REALLOC(*list, nelem + 1, char *); - if (ptr == NULL) - return NULL; - + ptr = XREALLOC(*list, nelem + 1, char *); ptr[nelem] = strsep(&s, ","); nelem++; *list = ptr; *nlist = nelem; } - ptr = REALLOC(*list, nelem + 1, char *); - if (ptr == NULL) - return NULL; - + ptr = XREALLOC(*list, nelem + 1, char *); ptr[nelem] = NULL; *list = ptr;