From 59f63ed5665aee5596ead0e8c79e883c4cb27bf3 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 29 Apr 2026 13:20:25 -0400 Subject: join: maybe truncate string --- src/lib/core/str.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/core/str.c b/src/lib/core/str.c index c80666b..447fc78 100644 --- a/src/lib/core/str.c +++ b/src/lib/core/str.c @@ -175,7 +175,7 @@ char *join(char **arr, const char *separator) { result = (char *)calloc(total_bytes, sizeof(char)); for (int i = 0; i < records; i++) { - strncat(result, arr[i], total_bytes - strlen(result) - 1); + strncat(result, arr[i], total_bytes - (result ? strlen(result) - 1 : 0)); if (i < (records - 1)) { strncat(result, separator, total_bytes - strlen(result) - 1); } -- cgit