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.

This commit is contained in:
The Dax committed 2013-08-27 08:08:06 -04:00
1 parent 2e25f00585
commit f70faaa0c2
1 file changed
+3 -1
+3 -1
View File
@@ -174,11 +174,13 @@ void GetWideStringFromPSPPointer(std::wstring& _string, const PSPPointer<u16_le>
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;