Fixed bug 1672 - Found: seg-fault with testgesture
authorSam Lantinga <slouken@libsdl.org>
Mon, 31 Dec 2012 14:08:43 -0800
changeset 6790475f0a544157
parent 6789 7177d421bb07
child 6791 c19c5232439d
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
     1.1 --- a/test/testgesture.c	Mon Dec 31 13:49:06 2012 -0800
     1.2 +++ b/test/testgesture.c	Mon Dec 31 14:08:43 2012 -0800
     1.3 @@ -94,8 +94,8 @@
     1.4    int y = (int)_y;
     1.5    float a;
     1.6    
     1.7 -  if(x < 0 || x > screen->w) return;
     1.8 -  if(y < 0 || y > screen->h) return;
     1.9 +  if(x < 0 || x >= screen->w) return;
    1.10 +  if(y < 0 || y >= screen->h) return;
    1.11  
    1.12    pixmem32 = (Uint32*) screen->pixels  + y*screen->pitch/BPP + x;
    1.13    
    1.14 @@ -195,7 +195,7 @@
    1.15    if (!window) {
    1.16      window = SDL_CreateWindow("Gesture Test",
    1.17                                SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
    1.18 -                              WIDTH, HEIGHT, SDL_WINDOW_RESIZABLE);
    1.19 +                              width, height, SDL_WINDOW_RESIZABLE);
    1.20    }
    1.21    if (!window) {
    1.22      return NULL;
    1.23 @@ -257,7 +257,7 @@
    1.24  	    break;
    1.25  	  case SDL_WINDOWEVENT:
    1.26              if (event.window.event == SDL_WINDOWEVENT_RESIZED) {
    1.27 -	      if (!(screen = initScreen(0, 0)))
    1.28 +	      if (!(screen = initScreen(event.window.data1, event.window.data2)))
    1.29  	      {
    1.30  		SDL_Quit();
    1.31  		return 1;