diff options
Diffstat (limited to 'tools/windows/compat.c')
-rw-r--r-- | tools/windows/compat.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/windows/compat.c b/tools/windows/compat.c index f0508b2..bce318b 100644 --- a/tools/windows/compat.c +++ b/tools/windows/compat.c @@ -61,13 +61,16 @@ int asprintf(char **strp, const char *fmt, ...) va_start(ap, fmt); len = _vscprintf(fmt, ap); + va_end(ap); + *strp = malloc(len+1); if (!*strp) return -1; - len = vsprintf(*strp, fmt, ap); - *strp[len] = 0; - + va_start(ap, fmt); + _vsnprintf(*strp, len+1, fmt, ap); va_end(ap); + + (*strp)[len] = 0; return len; } |