From f70faaa0c267ab5ed7fae8eb2c3e72c39eed2f81 Mon Sep 17 00:00:00 2001 From: The Dax Date: Tue, 27 Aug 2013 08:08:06 -0400 Subject: [PATCH] Terminate the loop early if it's going to overflow; there's no reason to keep riding it out. Also fix use of uninitialized variable. --- Core/Dialog/PSPOskDialog.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/Dialog/PSPOskDialog.cpp b/Core/Dialog/PSPOskDialog.cpp index 958f3d2cb7..b87b60bb7d 100755 --- a/Core/Dialog/PSPOskDialog.cpp +++ b/Core/Dialog/PSPOskDialog.cpp @@ -174,11 +174,13 @@ void GetWideStringFromPSPPointer(std::wstring& _string, const PSPPointer auto input = em_address; int c; - u32_le count; + u32_le count = 0; while ((c = *input++) != 0) { if ( !(++count >= maxLength) ) *string++ = c; + else + break; } *string++ = '\0'; _string = stringBuffer;