From 525ffee8adc9df289dd6eb4b65f70a2bb75940c3 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(-) diff --git a/src/lib/core/str.c b/src/lib/core/str.c index d66a819..5be3aa4 100644 --- a/src/lib/core/str.c +++ b/src/lib/core/str.c @@ -159,7 +159,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