Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug 1672 - Found: seg-fault with testgesture
Browse files Browse the repository at this point in the history
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
  • Loading branch information
slouken committed Dec 31, 2012
1 parent f7466bf commit c2b0888
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/testgesture.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c2b0888

Please sign in to comment.