diff --git a/src/ccode/string.c b/src/ccode/string.c index eb618eb..841a4ac 100755 --- a/src/ccode/string.c +++ b/src/ccode/string.c @@ -221,7 +221,14 @@ char* build_string(char* format, ...) { va_start(args, format); /* Determine the size needed for the string */ - int size = vsnprintf(NULL, 0, format, args) + 1; + int size = strlen(format); + const char *arg; + + /* Count the number of arguments until we hit a NULL */ + while ((arg = va_arg(args, const char *)) != NULL) { + size+= strlen(arg); + } + va_end(args); /* Allocate memory for the string */ @@ -232,7 +239,7 @@ char* build_string(char* format, ...) { /* Format the string */ va_start(args, format); - vsnprintf(result, size, format, args); + sprintf(result, format, args); va_end(args); return result;