From 68815b6c062f43fcaa3cc23dcc710a084c10e041 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Sun, 10 Jan 2021 22:21:12 +0100 Subject: [PATCH] Fixed bug 5465 - Invalid memcpy inside SDL_GestureDelTouch (Thanks dmikushin and Yuki Okumura) --- src/events/SDL_gesture.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index 9da9dd48c..c85b8dca2 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -487,7 +487,9 @@ int SDL_GestureDelTouch(SDL_TouchID touchId) SDL_zero(SDL_gestureTouch[i]); SDL_numGestureTouches--; - SDL_memcpy(&SDL_gestureTouch[i], &SDL_gestureTouch[SDL_numGestureTouches], sizeof(SDL_gestureTouch[i])); + if (i != SDL_numGestureTouches) { + SDL_memcpy(&SDL_gestureTouch[i], &SDL_gestureTouch[SDL_numGestureTouches], sizeof(SDL_gestureTouch[i])); + } return 0; }