Fixed bug 1672 - Found: seg-fault with testgesture
automata 2012-12-23 22:05:21 PST
An incorrect guard resulted in segmentation faults with the
SDL/test/testgesture executable. The attached patch fixes this issue, and also
allows the program's window to properly handle resize events.
Apply the attached patch to .../SDL/test/testgesture.c
--- a/test/testgesture.c Mon Dec 31 13:49:06 2012 -0800
+++ b/test/testgesture.c Mon Dec 31 14:08:43 2012 -0800
@@ -94,8 +94,8 @@
int y = (int)_y;
float a;
- if(x < 0 || x > screen->w) return;
- if(y < 0 || y > screen->h) return;
+ if(x < 0 || x >= screen->w) return;
+ if(y < 0 || y >= screen->h) return;
pixmem32 = (Uint32*) screen->pixels + y*screen->pitch/BPP + x;
@@ -195,7 +195,7 @@
if (!window) {
window = SDL_CreateWindow("Gesture Test",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
- WIDTH, HEIGHT, SDL_WINDOW_RESIZABLE);
+ width, height, SDL_WINDOW_RESIZABLE);
}
if (!window) {
return NULL;
@@ -257,7 +257,7 @@
break;
case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
- if (!(screen = initScreen(0, 0)))
+ if (!(screen = initScreen(event.window.data1, event.window.data2)))
{
SDL_Quit();
return 1;