Fixed bug #1056 (Frequent crashes in Touch events by simply touching the screen)
Joseba García Echebarria 2010-12-15 01:55:22 PST I believe the crash is caused by a check not being performed on wether an SDL_Touch element is NULL before using it in the SDL_SendTouchMotion function in src/events/SDL_touch.c around line 400. Judging from the rest of the code, there's a missing if (!touch) { return 0; } before using "touch" as SDL_GetFinger(), SDL_GetFingerIndexId() use touch->num_fingers without checking. I can attach a patch if you like. It seems pretty straightforward, though. I have yet to discover why touch is being returned as NULL as this error is only triggered when an actual gesture has been performed, maybe something related to SDL_AddTouch()?
This commit is contained in:
parent
c3daf0f0cd
commit
e64d0e8d85
1 changed files with 10 additions and 6 deletions
|
@ -397,15 +397,16 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative,
|
||||||
float xin, float yin, float pressurein)
|
float xin, float yin, float pressurein)
|
||||||
{
|
{
|
||||||
int index = SDL_GetTouchIndexId(id);
|
int index = SDL_GetTouchIndexId(id);
|
||||||
SDL_Touch *touch = SDL_GetTouch(id);
|
SDL_Touch *touch;
|
||||||
SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
|
SDL_Finger *finger;
|
||||||
int posted;
|
int posted;
|
||||||
Sint16 xrel, yrel;
|
Sint16 xrel, yrel;
|
||||||
float x_max = 0, y_max = 0;
|
float x_max = 0, y_max = 0;
|
||||||
Uint16 x;
|
Uint16 x;
|
||||||
Uint16 y;
|
Uint16 y;
|
||||||
Uint16 pressure;
|
Uint16 pressure;
|
||||||
|
|
||||||
|
touch = SDL_GetTouch(id);
|
||||||
if (!touch) {
|
if (!touch) {
|
||||||
return SDL_TouchNotFoundError(id);
|
return SDL_TouchNotFoundError(id);
|
||||||
}
|
}
|
||||||
|
@ -418,6 +419,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
finger = SDL_GetFinger(touch,fingerid);
|
||||||
if(finger == NULL || !finger->down) {
|
if(finger == NULL || !finger->down) {
|
||||||
return SDL_SendFingerDown(id,fingerid,SDL_TRUE,xin,yin,pressurein);
|
return SDL_SendFingerDown(id,fingerid,SDL_TRUE,xin,yin,pressurein);
|
||||||
} else {
|
} else {
|
||||||
|
@ -496,14 +498,16 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative,
|
||||||
return posted;
|
return posted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
SDL_SendTouchButton(SDL_TouchID id, Uint8 state, Uint8 button)
|
SDL_SendTouchButton(SDL_TouchID id, Uint8 state, Uint8 button)
|
||||||
{
|
{
|
||||||
SDL_Touch *touch = SDL_GetTouch(id);
|
SDL_Touch *touch;
|
||||||
int posted;
|
int posted;
|
||||||
Uint32 type;
|
Uint32 type;
|
||||||
|
|
||||||
|
|
||||||
|
touch = SDL_GetTouch(id);
|
||||||
if (!touch) {
|
if (!touch) {
|
||||||
return SDL_TouchNotFoundError(id);
|
return SDL_TouchNotFoundError(id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue