From 237872ae44b1b3debb96e4f96d21c3c06dbdf761 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sat, 25 Apr 2026 10:16:36 -0400 Subject: strdup_array: handle allocation errors --- src/lib/core/str.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/lib') 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]) { -- cgit