diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-03-22 18:18:57 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2024-03-22 22:20:30 -0400 |
commit | 7fe5152be4e9dc4f9aa707eb5640c35aad8ecbce (patch) | |
tree | 20324d11299f6f88dd7ba85309b368eaf5811614 | |
parent | d5cc5d9339d09676f365a695337ed98ffdb74b64 (diff) | |
download | stasis-7fe5152be4e9dc4f9aa707eb5640c35aad8ecbce.tar.gz |
Fix realloc error handling
-rw-r--r-- | src/strlist.c | 3 |
1 files changed, 2 insertions, 1 deletions
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); |