diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-25 10:16:36 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-25 10:16:36 -0400 |
| commit | 237872ae44b1b3debb96e4f96d21c3c06dbdf761 (patch) | |
| tree | 0210e98e4b9123eda25ecbaae7696315abaae1fd | |
| parent | 7b7d84b3bea179d607fae2db5de7613adef1a6fd (diff) | |
| download | stasis-237872ae44b1b3debb96e4f96d21c3c06dbdf761.tar.gz | |
strdup_array: handle allocation errors
| -rw-r--r-- | src/lib/core/str.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lib/core/str.c b/src/lib/core/str.c index b04dfed..a08bd2b 100644 --- a/src/lib/core/str.c +++ b/src/lib/core/str.c @@ -587,6 +587,10 @@ char **strdup_array(char **array) { // Create new array result = calloc(elems + 1, sizeof(*result)); + if (!result) { + SYSERROR("%s", "could not allocate memory for result array"); + return NULL; + } for (size_t i = 0; i < elems; i++) { result[i] = strdup(array[i]); if (!result[i]) { |
