We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5456

Summary: Invalid memcpy inside SDL_GestureDelTouch
Product: SDL Reporter: Yuki Okumura <mjt>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sylvain.becker
Version: HG 2.1   
Hardware: Other   
OS: Android (All)   
Attachments: src/events/SDL_gesture.c: Patch proposal

Description Yuki Okumura 2021-01-10 13:11:34 UTC
Created attachment 4655 [details]
src/events/SDL_gesture.c: Patch proposal

(Reported as: https://github.com/spurious/SDL-mirror/pull/14 )

In function SDL_GestureDelTouch(), when deleting the final entry it might do overlapping memcpy because it might do:

> SDL_memcpy(&SDL_gestureTouch[0], &SDL_gestureTouch[0], sizeof(SDL_gestureTouch[i]));

memcpy should not be used for overlapping region, but anyway, it does not need to be done.

Attached is @dmikushin's patch that adds check and skip memcpy when removing the final entry.
Comment 1 Sylvain 2021-01-10 21:22:46 UTC
Thanks, added in :
https://hg.libsdl.org/SDL/rev/17d911637a65

slightly differently: checking: (i != SDL_numGestureTouches)