Merge pull request #5290 from neomonkey/master

StringUtil: Fix possible bad free
This commit is contained in:
Léo Lam 2018-03-26 23:56:25 +02:00 committed by GitHub
commit c55b3a664d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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