From a2701faa2bbbb33bcb79d73cc2597806c4f96490 Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Wed, 20 Feb 2019 21:22:24 -0500 Subject: [PATCH] Floss Finder: Igor Igor is a dentist with more on his "plate" than he can handle Watch as Igor tries to find all the floss in his patients' mouths Starring Timmy the Tooth, and the Tooth Fairy; join all your favorite oral hygiene friends in helping Igor solve his terrible tooth travesty! (May contain traces of knockoff pokemon, talk to your dietician before consumption) --- indra/llcommon/llformat.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/indra/llcommon/llformat.cpp b/indra/llcommon/llformat.cpp index f9f16006a..319afda94 100644 --- a/indra/llcommon/llformat.cpp +++ b/indra/llcommon/llformat.cpp @@ -41,13 +41,17 @@ // wrapper for vsnprintf to be called from llformatXXX functions. static void va_format(std::string& out, const char *fmt, va_list va) { - char tstr[1024]; /* Flawfinder: ignore */ -#if LL_WINDOWS - _vsnprintf(tstr, 1024, fmt, va); -#else - vsnprintf(tstr, 1024, fmt, va); /* Flawfinder: ignore */ -#endif - out.assign(tstr); + constexpr auto smallsize = 1024; + std::vector charvector(smallsize); // Evolves into charveleon + va_list va2; + va_copy(va2, va); + const auto size = std::vsnprintf(charvector.data(), charvector.size(), fmt, va); + if (size >= smallsize) + { + charvector.resize(1+size); // Use the String Stone + std::vsnprintf(charvector.data(), charvector.size(), fmt, va2); + } + out.assign(charvector.data()); } std::string llformat(const char *fmt, ...)