From 7169be242f1c215d21736485cd03adf0b36a1af9 Mon Sep 17 00:00:00 2001 From: Miikka Juomoja Date: Sat, 8 Apr 2017 18:05:12 +0300 Subject: [PATCH] StringUtil: Fix possible bad free --- Source/Core/Common/StringUtil.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/Common/StringUtil.cpp b/Source/Core/Common/StringUtil.cpp index 8ac8a4a229..4216d0f6f6 100644 --- a/Source/Core/Common/StringUtil.cpp +++ b/Source/Core/Common/StringUtil.cpp @@ -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