mirror of https://github.com/mgba-emu/mgba.git
Vita: Fix keyboard result bounds check
This commit is contained in:
parent
4508797e35
commit
7982de2a4c
|
@ -132,9 +132,17 @@ static enum GUIKeyboardStatus _keyboardRun(struct GUIKeyboardParams* keyboard) {
|
||||||
utf16Buffer = params.inputTextBuffer;
|
utf16Buffer = params.inputTextBuffer;
|
||||||
utf8Buffer = keyboard->result;
|
utf8Buffer = keyboard->result;
|
||||||
i = keyboard->maxLen;
|
i = keyboard->maxLen;
|
||||||
while (i > 0 && *utf16Buffer) {
|
size_t bufferSize = sizeof(SceWChar16) * keyboard->maxLen;
|
||||||
uint32_t unichar = utf16Char((const uint16_t**) &utf16Buffer, &i);
|
while (bufferSize && *utf16Buffer) {
|
||||||
utf8Buffer += toUtf8(unichar, utf8Buffer);
|
char buffer[4];
|
||||||
|
uint32_t unichar = utf16Char((const uint16_t**) &utf16Buffer, &bufferSize);
|
||||||
|
size_t bytes = toUtf8(unichar, buffer);
|
||||||
|
if (i < bytes) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
memcpy(utf8Buffer, buffer, bytes);
|
||||||
|
utf8Buffer += bytes;
|
||||||
|
i -= bytes;
|
||||||
}
|
}
|
||||||
utf8Buffer[0] = 0;
|
utf8Buffer[0] = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue