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 - Invalid memcpy inside SDL_GestureDelTouch
Summary: Invalid memcpy inside SDL_GestureDelTouch
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.1
Hardware: Other Android (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-10 13:11 UTC by Yuki Okumura
Modified: 2021-01-10 21:22 UTC (History)
1 user (show)

See Also:


Attachments
src/events/SDL_gesture.c: Patch proposal (920 bytes, patch)
2021-01-10 13:11 UTC, Yuki Okumura
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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)