From 191a6417d581b79cab5698dee84554ea64b5ac61 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Tue, 14 Jan 2025 23:15:14 +0100 Subject: [PATCH] events: use SDL_memmove instead of SDL_memcpy for overlapping memory --- src/events/SDL_keyboard.c | 2 +- src/events/SDL_mouse.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 30e35ad5f9..46e28deff9 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -160,7 +160,7 @@ void SDL_RemoveKeyboard(SDL_KeyboardID keyboardID, bool send_event) SDL_free(SDL_keyboards[keyboard_index].name); if (keyboard_index != SDL_keyboard_count - 1) { - SDL_memcpy(&SDL_keyboards[keyboard_index], &SDL_keyboards[keyboard_index + 1], (SDL_keyboard_count - keyboard_index - 1) * sizeof(SDL_keyboards[keyboard_index])); + SDL_memmove(&SDL_keyboards[keyboard_index], &SDL_keyboards[keyboard_index + 1], (SDL_keyboard_count - keyboard_index - 1) * sizeof(SDL_keyboards[keyboard_index])); } --SDL_keyboard_count; diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index bfdabb9fff..becfe28e5d 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -328,7 +328,7 @@ void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event) SDL_free(SDL_mice[mouse_index].name); if (mouse_index != SDL_mouse_count - 1) { - SDL_memcpy(&SDL_mice[mouse_index], &SDL_mice[mouse_index + 1], (SDL_mouse_count - mouse_index - 1) * sizeof(SDL_mice[mouse_index])); + SDL_memmove(&SDL_mice[mouse_index], &SDL_mice[mouse_index + 1], (SDL_mouse_count - mouse_index - 1) * sizeof(SDL_mice[mouse_index])); } --SDL_mouse_count; @@ -339,7 +339,7 @@ void SDL_RemoveMouse(SDL_MouseID mouseID, bool send_event) if (source->mouseID == mouseID) { SDL_free(source->clickstate); if (i != mouse->num_sources - 1) { - SDL_memcpy(&mouse->sources[i], &mouse->sources[i + 1], (mouse->num_sources - i - 1) * sizeof(mouse->sources[i])); + SDL_memmove(&mouse->sources[i], &mouse->sources[i + 1], (mouse->num_sources - i - 1) * sizeof(mouse->sources[i])); } --mouse->num_sources; break;