Fixed bug 5465 - Invalid memcpy inside SDL_GestureDelTouch (Thanks dmikushin and Yuki Okumura)
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;
}