Check if second vsnprintf does something unexpected

develop
Pauli 2018-06-13 18:56:30 +03:00
parent 82e7b8300a
commit 4cfdd7d92e
1 changed files with 4 additions and 0 deletions

@ -27,6 +27,8 @@ distribution.
#include "MiscUtils.h"
#ifndef LINUX_BUILD
// We don't want min and max macros
#define NOMINMAX
#include <Windows.h>
#else
#include <sys/time.h>
@ -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<int>(rv.size()))
rv.resize(std::max(rsz+1,0));
return rv;
}