From 7fe5152be4e9dc4f9aa707eb5640c35aad8ecbce Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Fri, 22 Mar 2024 18:18:57 -0400 Subject: Fix realloc error handling --- src/strlist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/strlist.c b/src/strlist.c index 9e9bafb..bcb71dd 100644 --- a/src/strlist.c +++ b/src/strlist.c @@ -42,8 +42,9 @@ void strlist_append(struct StrList *pStrList, char *str) { strlist_free(pStrList); perror("failed to append to array"); exit(1); + } else if (tmp != pStrList->data) { + pStrList->data = tmp; } - pStrList->data = tmp; pStrList->data[pStrList->num_inuse] = strdup(str); pStrList->data[pStrList->num_alloc] = NULL; strcpy(pStrList->data[pStrList->num_inuse], str); -- cgit