From: Guus Sliepen Date: Wed, 17 Jul 2013 16:06:56 +0000 (+0200) Subject: Don't use vasprintf() anymore on Windows. X-Git-Tag: release-1.1pre8~27 X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=commitdiff_plain;h=182890814881be90e28ac5183039e25709766992 Don't use vasprintf() anymore on Windows. Windows doesn't actually support it, but MinGW provides it. However, with some versions of MinGW it doesn't work correctly. Instead, we vsnprintf() to a local buffer and xstrdup() the results. --- diff --git a/src/xalloc.h b/src/xalloc.h index 6629b60b..28960fbd 100644 --- a/src/xalloc.h +++ b/src/xalloc.h @@ -52,9 +52,17 @@ static inline char *xstrdup(const char *s) { } static inline int xvasprintf(char **strp, const char *fmt, va_list ap) { +#ifdef HAVE_MINGW + char buf[1024]; + int result = vsnprintf(buf, sizeof buf, fmt, ap); + if(result < 0) + abort(); + *strp = xstrdup(buf); +#else int result = vasprintf(strp, fmt, ap); if(result < 0) abort(); +#endif return result; }