aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2026-06-04 13:17:31 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2026-06-22 10:13:58 -0400
commit2da62a16c533017fc332b47af1a44892e8981b8b (patch)
treedaf4c7e619c107dfc1f29536a252a2f2318cab01
parent91f5f53d0a3f06002b102924bb50f3e3b3f62e9b (diff)
downloadstasis-2da62a16c533017fc332b47af1a44892e8981b8b.tar.gz
join_ex: Fix leak on memory error
-rw-r--r--src/lib/core/str.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/core/str.c b/src/lib/core/str.c
index f3ec9f7..84a325b 100644
--- a/src/lib/core/str.c
+++ b/src/lib/core/str.c
@@ -229,6 +229,11 @@ char *join_ex(char *separator, ...) {
// Generate output string
result = calloc(size + 1, sizeof(char));
+ if (!result) {
+ guard_array_free_by_count(argv, argc);
+ return NULL;
+ }
+
for (size_t i = 0; i < argc; i++) {
// Append argument to string
safe_strncat(result, argv[i], size + 1); // no -1 because +1 above