Commit 68815b6c062f43fcaa3cc23dcc710a084c10e041

Sylvain Becker 2021-01-10T22:21:12

Fixed bug 5465 - Invalid memcpy inside SDL_GestureDelTouch (Thanks dmikushin and Yuki Okumura)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c
index 9da9dd4..c85b8dc 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;
 }