From a0744c8dcab86845e9f2e9060c84a610bd496dd9 Mon Sep 17 00:00:00 2001 From: Lee Thomason Date: Sun, 16 Mar 2014 10:32:27 -0700 Subject: [PATCH] fix implementation of much simpler visual studio printing --- tinyxml2.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index ef33c4e..a64dad6 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1855,7 +1855,7 @@ void XMLPrinter::Print( const char* format, ... ) vfprintf( _fp, format, va ); } else { -#ifdef _MSC_VER +#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) int len = _vscprintf( format, va ); #else int len = vsnprintf( 0, 0, format, va ); @@ -1863,8 +1863,12 @@ void XMLPrinter::Print( const char* format, ... ) // Close out and re-start the va-args va_end( va ); va_start( va, format ); - char* p = _buffer.PushArr( len ) - 1; - vsnprintf( p, len+1, format, va ); + char* p = _buffer.PushArr( len ) - 1; // back up over the null terminator. +#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + vsnprintf_s( p, len+1, _TRUNCATE, format, va ); +#else + vsnprintf( p, len+1, format, va ); +#endif } va_end( va ); }