Prevent division-by-zero in WarpMouse if surface's pitch is zero (a GL surface?).
authorRyan C. Gordon
Sun, 30 Oct 2005 05:45:46 +0000
changeset 116396ef83467667
parent 1162 2651158f59b8
child 1164 10b3fb28c86b
Prevent division-by-zero in WarpMouse if surface's pitch is zero (a GL surface?).
src/video/SDL_cursor.c
     1.1 --- a/src/video/SDL_cursor.c	Thu Oct 20 06:55:26 2005 +0000
     1.2 +++ b/src/video/SDL_cursor.c	Sun Oct 30 05:45:46 2005 +0000
     1.3 @@ -303,9 +303,14 @@
     1.4  	}
     1.5  
     1.6  	/* If we have an offset video mode, offset the mouse coordinates */
     1.7 -	x += (this->screen->offset % this->screen->pitch) /
     1.8 -	      this->screen->format->BytesPerPixel;
     1.9 -	y += (this->screen->offset / this->screen->pitch);
    1.10 +	if (this->screen->pitch == 0) {
    1.11 +		x += this->screen->offset / this->screen->format->BytesPerPixel;
    1.12 +		y += this->screen->offset;
    1.13 +	} else {
    1.14 +		x += (this->screen->offset % this->screen->pitch) /
    1.15 +		      this->screen->format->BytesPerPixel;
    1.16 +		y += (this->screen->offset / this->screen->pitch);
    1.17 +	}
    1.18  
    1.19  	/* This generates a mouse motion event */
    1.20  	if ( video->WarpWMCursor ) {