diff options
author | madmaxoft <github@xoft.cz> | 2014-01-15 17:46:14 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-01-15 17:46:29 +0100 |
commit | 3fd19df9fd7ccd1f24f72b69fbe9e1122102532e (patch) | |
tree | c92bb12fdde87d67df067378501fbfc8ef24e2b5 /src/StringUtils.cpp | |
parent | Merge pull request #543 from mc-server/Furnace_Minecarts (diff) | |
download | cuberite-3fd19df9fd7ccd1f24f72b69fbe9e1122102532e.tar cuberite-3fd19df9fd7ccd1f24f72b69fbe9e1122102532e.tar.gz cuberite-3fd19df9fd7ccd1f24f72b69fbe9e1122102532e.tar.bz2 cuberite-3fd19df9fd7ccd1f24f72b69fbe9e1122102532e.tar.lz cuberite-3fd19df9fd7ccd1f24f72b69fbe9e1122102532e.tar.xz cuberite-3fd19df9fd7ccd1f24f72b69fbe9e1122102532e.tar.zst cuberite-3fd19df9fd7ccd1f24f72b69fbe9e1122102532e.zip |
Diffstat (limited to '')
-rw-r--r-- | src/StringUtils.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 0b38297ef..2dcd9fec9 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -28,6 +28,10 @@ AString & AppendVPrintf(AString & str, const char *format, va_list args) // MS CRT provides secure printf that doesn't behave like in the C99 standard if ((len = _vsnprintf_s(buffer, ARRAYCOUNT(buffer), _TRUNCATE, format, args)) != -1) #else // _MSC_VER + // We need to store a copy of the args, because on AMD64 in GCC the vsnprintf() is allowed to make changes to it (WTF?) + // Ref.: issue #541, http://www.bailopan.net/blog/?p=30 + va_list args2; + va_copy(args2, args); if ((len = vsnprintf(buffer, ARRAYCOUNT(buffer), format, args)) < ARRAYCOUNT(buffer)) #endif // else _MSC_VER { @@ -51,7 +55,7 @@ AString & AppendVPrintf(AString & str, const char *format, va_list args) #ifdef _MSC_VER vsprintf_s((char *)&(Buffer.front()), Buffer.size(), format, args); #else // _MSC_VER - vsnprintf((char *)&(Buffer.front()), Buffer.size(), format, args); + vsnprintf((char *)&(Buffer.front()), Buffer.size(), format, args2); #endif // else _MSC_VER str.append(&(Buffer.front()), Buffer.size() - 1); return str; |