From 011cd7ffdb48b1cf66c7c9e250e7cd134d38c764 Mon Sep 17 00:00:00 2001 From: Jack Jamison Date: Fri, 31 Jul 2026 00:08:11 -0400 Subject: fix "overflow" (my fault) --- .gitignore | 3 ++- snag/src/util.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 9b253e1..b2c6902 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -lfs.qcow2 \ No newline at end of file +lfs.qcow2 +/misc/images/ diff --git a/snag/src/util.c b/snag/src/util.c index 025e583..ab0b7e6 100644 --- a/snag/src/util.c +++ b/snag/src/util.c @@ -101,14 +101,19 @@ char* join_path_(int dummy, ...) { int i = 0; while ((arg = va_arg(args, char*))) { if (i > 0) len += 1; - len += strlen(arg) + 1; + len += strlen(arg); ++i; } va_end(args); - // allocate and build output + // allocate output string char* output = malloc(len + 1); - if (!output) return NULL; + if (!output) { + va_end(args2); + return NULL; + } + + // build output string char* p = output; while ((arg = va_arg(args2, char*))) { if (p != output) { -- cgit v1.2.3