Fix vsnprintf handling for MSVC compiler

Add handling for MSVC's vsnprintf behavior
This commit is contained in:
deepend-tildeclub
2026-02-16 00:45:59 -07:00
committed by GitHub
parent c815a4629c
commit 2bfd96c9e0

View File

@@ -588,7 +588,16 @@ static char *zoitechat_strdup_printf (const char *format, ...)
va_start (args, format);
va_copy (args_copy, args);
/*
* MSVC's debug CRT treats vsnprintf(NULL, 0, ...) as an invalid parameter,
* which triggers a fatal runtime exception via ucrtbased.dll. Use
* _vscprintf() to determine required output length on that toolchain.
*/
#ifdef _MSC_VER
length = _vscprintf (format, args_copy);
#else
length = vsnprintf (NULL, 0, format, args_copy);
#endif
va_end (args_copy);
if (length < 0)