diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-29 11:52:30 +0100 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-29 11:59:24 +0100 |
| commit | e51027a576a07ffb41b6e7d2bfc3aade6ae091d7 (patch) | |
| tree | 1d30aa7156f5a470a20bfab9d9c697829e2aca25 /src/input.c | |
| parent | f9950fce6f7b7a3743920f0d787fb1857aa05769 (diff) | |
Minor Fixes
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; } |
