diff options
Diffstat (limited to 'src/input.c')
| -rw-r--r-- | src/input.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/input.c b/src/input.c index eec088e..8e2ee33 100644 --- a/src/input.c +++ b/src/input.c @@ -33,6 +33,7 @@ void pw_input_free(struct pw_input *input) { return; } + SDL_free(input->clipboard.buffer); SDL_free(input); } @@ -53,7 +54,11 @@ bool pw_input_reset(struct pw_input *input, struct pw_players *players) { SDL_zeroa(input->players); clear_queue(&input->keyboard.scancodes); - clear_queue(&input->keyboard.scancodes); + clear_queue(&input->keyboard.text); + + SDL_zerop(&input->mouse.rel); + + *input->clipboard.buffer = '\0'; return true; } @@ -584,7 +589,10 @@ bool pw_input_clipboard_commit(struct pw_input *input) { return SDL_InvalidParamError("input"); } + // Just to be sure always make the buffer end with NUL to prevent reads + // past the end of the buffer. input->clipboard.buffer[input->clipboard.size - 1] = '\0'; + return SDL_SetClipboardText(input->clipboard.buffer); } @@ -601,6 +609,9 @@ bool pw_input_clipboard_fetch(struct pw_input *input, size_t *len) { char *text = SDL_GetClipboardText(); if (!text || !*text) { + if (text) { + SDL_free(text); + } return false; } |
