From 834bcd7bcdaa8eb71fa382d12535cb1af7e9cc16 Mon Sep 17 00:00:00 2001 From: spx Date: Sat, 24 Sep 2011 13:41:07 +0000 Subject: [PATCH] Fixed crash when the string resource is not found in Language.dll. --- Library/Litestep.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Library/Litestep.cpp b/Library/Litestep.cpp index 13f886c2..9eda88d5 100644 --- a/Library/Litestep.cpp +++ b/Library/Litestep.cpp @@ -745,7 +745,7 @@ std::wstring GetFormattedString(UINT id, ...) va_list args = NULL; va_start(args, id); - FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER, + DWORD len = FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ALLOCATE_BUFFER, GetString(id), 0, 0, @@ -755,8 +755,8 @@ std::wstring GetFormattedString(UINT id, ...) va_end(args); - std::wstring tmpSz = pBuffer; - LocalFree(pBuffer); + std::wstring tmpSz(len ? pBuffer : L""); + if (pBuffer) LocalFree(pBuffer); return tmpSz; }