From 350ac1e2e8990a9b122dc9f70792d59d02da312d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 29 Apr 2016 19:40:44 -0700 Subject: [PATCH] Fixed vsnprintf. --- include/bx/string.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/bx/string.h b/include/bx/string.h index 6b7dc72..8932df4 100644 --- a/include/bx/string.h +++ b/include/bx/string.h @@ -307,7 +307,9 @@ namespace bx inline int32_t vsnprintf(char* _str, size_t _count, const char* _format, va_list _argList) { #if BX_COMPILER_MSVC - int32_t len = ::vsnprintf_s(_str, _count, size_t(-1), _format, _argList); + va_list argListCopy; + va_copy(argListCopy, _argList); + int32_t len = ::vsnprintf_s(_str, _count, size_t(-1), _format, argListCopy); return -1 == len ? ::_vscprintf(_format, _argList) : len; #else return ::vsnprintf(_str, _count, _format, _argList); @@ -320,7 +322,9 @@ namespace bx inline int32_t vsnwprintf(wchar_t* _str, size_t _count, const wchar_t* _format, va_list _argList) { #if BX_COMPILER_MSVC - int32_t len = ::_vsnwprintf_s(_str, _count, size_t(-1), _format, _argList); + va_list argListCopy; + va_copy(argListCopy, _argList); + int32_t len = ::_vsnwprintf_s(_str, _count, size_t(-1), _format, argListCopy); return -1 == len ? ::_vscwprintf(_format, _argList) : len; #elif defined(__MINGW32__) return ::vsnwprintf(_str, _count, _format, _argList);