StringUtil: Fix possible bad free

This commit is contained in:
Miikka Juomoja 2017-04-08 18:05:12 +03:00 committed by Léo Lam
parent 793c6d25f4
commit 7169be242f
1 changed files with 4 additions and 0 deletions

View File

@ -173,7 +173,11 @@ std::string StringFromFormatV(const char* format, va_list args)
locale_t previousLocale = uselocale(GetCLocale());
#endif
if (vasprintf(&buf, format, args) < 0)
{
ERROR_LOG(COMMON, "Unable to allocate memory for string");
buf = nullptr;
}
#if !defined(ANDROID) && !defined(__HAIKU__) && !defined(__OpenBSD__)
uselocale(previousLocale);
#endif