summaryrefslogtreecommitdiff
path: root/Source/Core/Common/StringUtil.cpp
diff options
context:
space:
mode:
authorMiikka Juomoja <miikka.juomoja@live.com>2017-04-08 18:05:12 +0300
committerLéo Lam <leo@innovatetechnologi.es>2018-03-26 23:48:13 +0200
commit7169be242f1c215d21736485cd03adf0b36a1af9 (patch)
treec57c11352fca10af6968bafc285fa0c3ba44f6ea /Source/Core/Common/StringUtil.cpp
parent793c6d25f487f4ff382d58f04c3827c41bc59cd3 (diff)
StringUtil: Fix possible bad free
Diffstat (limited to 'Source/Core/Common/StringUtil.cpp')
-rw-r--r--Source/Core/Common/StringUtil.cpp4
1 files changed, 4 insertions, 0 deletions
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