From 58ca962d89b29cb66c91dd97a6e6fe9aa90084c2 Mon Sep 17 00:00:00 2001 From: The Dax Date: Tue, 27 Aug 2013 07:44:32 -0400 Subject: [PATCH] Prevent possible buffer overflow. --- Core/Dialog/PSPOskDialog.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 9eb4c63524..112909658d 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -162,13 +162,14 @@ void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, const PSPPointer em_address) { - if (!em_address.IsValid()) + const size_t maxLength = 2048; + if (!em_address.IsValid() || _string.length() >= maxLength) { _string = L""; return; } - wchar_t stringBuffer[2048]; + wchar_t stringBuffer[maxLength]; wchar_t *string = stringBuffer; auto input = em_address;