Before this patch, the function looped while (s != NULL && *s != '\0').
However, nothing was modifying that string if REALLOC() failed, so the
loop was forever.
Fixes: 8e167d28afd6 ("[svn-upgrade] Integrating new upstream version, shadow (4.0.8)")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
while (s != NULL && *s != '\0') {
size = (nelem + 1) * sizeof (ptr);
ptr = REALLOC(*list, size, char *);
- if (NULL != ptr) {
- ptr[nelem] = strsep(&s, ",");
- nelem++;
- *list = ptr;
- *nlist = nelem;
- }
+ if (ptr == NULL)
+ return NULL;
+
+ ptr[nelem] = strsep(&s, ",");
+ nelem++;
+ *list = ptr;
+ *nlist = nelem;
}
+
size = (nelem + 1) * sizeof (ptr);
ptr = REALLOC(*list, size, char *);
- if (NULL != ptr) {
- ptr[nelem] = NULL;
- *list = ptr;
- }
+ if (ptr == NULL)
+ return NULL;
+
+ ptr[nelem] = NULL;
+ *list = ptr;
+
return ptr;
}