It's undefined behavior to use the same va_list twice.
This most likely didn't cause any issues in practice since the string would
have to be larger than 4 KiB to trigger the fallback path.
Use workaround for ICL as it doesn't define va_copy even for C99.
{
char buf[4096];
wchar_t buf_utf16[4096];
+ va_list arg2;
+
+ va_copy( arg2, arg );
+ int length = vsnprintf( buf, sizeof(buf), format, arg2 );
+ va_end( arg2 );
- int length = vsnprintf( buf, sizeof(buf), format, arg );
if( length > 0 && length < sizeof(buf) )
{
/* WriteConsoleW is the most reliable way to output Unicode to a console. */
#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
#endif
+#if !defined(va_copy) && defined(__INTEL_COMPILER)
+#define va_copy(dst, src) ((dst) = (src))
+#endif
+
#if !defined(isfinite) && (SYS_OPENBSD || SYS_SunOS)
#define isfinite finite
#endif