From bd822fffa613510256798b25dd5f7d4ae93fd59a Mon Sep 17 00:00:00 2001 From: Stephen Hill Date: Sun, 1 May 2016 18:31:24 -0400 Subject: [PATCH] Fixed reuse of va_list in traceVargs It's not safe to reuse va_list over multiple var-arg calls. --- src/bgfx.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index bf5f020f4..5da3c5609 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -65,8 +65,11 @@ namespace bgfx { char temp[2048]; char* out = temp; + va_list argListCopy; + va_copy(argListCopy, _argList); int32_t len = bx::snprintf(out, sizeof(temp), "%s (%d): ", _filePath, _line); - int32_t total = len + bx::vsnprintf(out + len, sizeof(temp)-len, _format, _argList); + int32_t total = len + bx::vsnprintf(out + len, sizeof(temp)-len, _format, argListCopy); + va_end(argListCopy); if ( (int32_t)sizeof(temp) < total) { out = (char*)alloca(total+1);