diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | snag/src/util.c | 11 |
2 files changed, 10 insertions, 4 deletions
@@ -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) { |
