Prevent division-by-zero in WarpMouse if surface's pitch is zero (a GL surface?).
authorRyan C. Gordon <icculus@icculus.org>
Sun, 30 Oct 2005 05:45:46 +0000
changeset 1163 96ef83467667
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
--- a/src/video/SDL_cursor.c	Thu Oct 20 06:55:26 2005 +0000
+++ b/src/video/SDL_cursor.c	Sun Oct 30 05:45:46 2005 +0000
@@ -303,9 +303,14 @@
 	}
 
 	/* If we have an offset video mode, offset the mouse coordinates */
-	x += (this->screen->offset % this->screen->pitch) /
-	      this->screen->format->BytesPerPixel;
-	y += (this->screen->offset / this->screen->pitch);
+	if (this->screen->pitch == 0) {
+		x += this->screen->offset / this->screen->format->BytesPerPixel;
+		y += this->screen->offset;
+	} else {
+		x += (this->screen->offset % this->screen->pitch) /
+		      this->screen->format->BytesPerPixel;
+		y += (this->screen->offset / this->screen->pitch);
+	}
 
 	/* This generates a mouse motion event */
 	if ( video->WarpWMCursor ) {