diff --git a/library/MiscUtils.cpp b/library/MiscUtils.cpp index ee64ffaee..bbb363e10 100644 --- a/library/MiscUtils.cpp +++ b/library/MiscUtils.cpp @@ -27,6 +27,8 @@ distribution. #include "MiscUtils.h" #ifndef LINUX_BUILD +// We don't want min and max macros +#define NOMINMAX #include #else #include @@ -67,6 +69,8 @@ std::string stl_vsprintf(const char *fmt, va_list args) { // Allocate enough memory for the output and null termination rv.resize(rsz+1); rsz = vsnprintf(&rv[0], rv.size(), fmt, args); + if (rsz + 1 < static_cast(rv.size())) + rv.resize(std::max(rsz+1,0)); return rv; }