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 2503

Summary: Loop indexing and event union errors in SDL_gesture.c
Product: SDL Reporter: Lasse Öörni <loorni>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.3   
Hardware: All   
OS: All   

Description Lasse Öörni 2014-04-17 13:38:38 UTC
While enabling $1 gesture support in the Urho3D engine which uses SDL2 I detected some errors in the gesture code in SDL_gesture.c:

- In the function SDL_SaveAllDollarTemplates() the following line should use index variable j instead of i:

    rtrn += SaveTemplate(&touch->dollarTemplate[i], dst);

- In the function SDL_SaveDollarTemplate() the following code should use index variable j instead of i:

    if (touch->dollarTemplate[i].hash == gestureId) {
        return SaveTemplate(&touch->dollarTemplate[i], dst);

- In the function SDL_SendGestureDollar() the x & y coordinates are being written to the mgesture structure, which results in garbage due to dgesture and mgesture being different data structures inside the union. The coordinates should be written to dgesture.x & dgesture.y respectively
Comment 1 Sam Lantinga 2014-04-18 02:53:28 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/fee2f7e242a1
Comment 2 Lasse Öörni 2014-04-18 11:36:02 UTC
Thanks for the quick response! I looked at the hg repo, there's still one line which is using the wrong index variable in SDL_SaveDollarTemplate():

    if (touch->dollarTemplate[i].hash == gestureId) {
Comment 3 Sam Lantinga 2014-04-19 17:17:53 UTC
Fixed, thanks!