mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Really prevent the possible buffer overflow. This is getting silly.
This commit is contained in:
parent
58ca962d89
commit
2e25f00585
1 changed files with 5 additions and 3 deletions
|
@ -162,21 +162,23 @@ void PSPOskDialog::ConvertUCS2ToUTF8(std::string& _string, const PSPPointer<u16_
|
|||
|
||||
void GetWideStringFromPSPPointer(std::wstring& _string, const PSPPointer<u16_le> em_address)
|
||||
{
|
||||
const size_t maxLength = 2048;
|
||||
if (!em_address.IsValid() || _string.length() >= maxLength)
|
||||
if (!em_address.IsValid())
|
||||
{
|
||||
_string = L"";
|
||||
return;
|
||||
}
|
||||
const size_t maxLength = 2048;
|
||||
|
||||
wchar_t stringBuffer[maxLength];
|
||||
wchar_t *string = stringBuffer;
|
||||
|
||||
auto input = em_address;
|
||||
int c;
|
||||
u32_le count;
|
||||
while ((c = *input++) != 0)
|
||||
{
|
||||
*string++ = c;
|
||||
if ( !(++count >= maxLength) )
|
||||
*string++ = c;
|
||||
}
|
||||
*string++ = '\0';
|
||||
_string = stringBuffer;
|
||||
|
|
Loading…
Add table
Reference in a new issue