From c2b088810cf6a20d0a4b2142624d20cabcd20a2f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 31 Dec 2012 14:08:43 -0800 Subject: [PATCH] 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 --- test/testgesture.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/testgesture.c b/test/testgesture.c index dd2d7a0fd..04c0e176b 100644 --- a/test/testgesture.c +++ b/test/testgesture.c @@ -94,8 +94,8 @@ void setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) 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 @@ SDL_Surface* initScreen(int width,int height) 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 @@ int main(int argc, char* argv[]) 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;