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; }