mirror of
https://github.com/shadps4-emu/ext-SDL.git
synced 2024-12-24 03:35:09 +00:00
Fixed infinite loop when SDL_SendKeyboardText() is passed invalid UTF-8 text
This commit is contained in:
parent
954bbdf3ae
commit
0cd5b08bfe
@ -914,12 +914,16 @@ SDL_SendKeyboardText(const char *text)
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||
SDL_Event event;
|
||||
size_t i = 0, length = SDL_strlen(text);
|
||||
size_t pos = 0, advance, length = SDL_strlen(text);
|
||||
|
||||
event.text.type = SDL_TEXTINPUT;
|
||||
event.text.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
while (i < length) {
|
||||
i += SDL_utf8strlcpy(event.text.text, text + i, SDL_arraysize(event.text.text));
|
||||
while (pos < length) {
|
||||
advance = SDL_utf8strlcpy(event.text.text, text + pos, SDL_arraysize(event.text.text));
|
||||
if (!advance) {
|
||||
break;
|
||||
}
|
||||
pos += advance;
|
||||
posted |= (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user