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 - Loop indexing and event union errors in SDL_gesture.c
Summary: Loop indexing and event union errors in SDL_gesture.c
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.3
Hardware: All All
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-17 13:38 UTC by Lasse Öörni
Modified: 2014-04-19 17:17 UTC (History)
0 users

See Also:


Attachments

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