changeset 1163:96ef83467667

Prevent division-by-zero in WarpMouse if surface's pitch is zero (a GL surface?).
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 30 Oct 2005 05:45:46 +0000
parents 2651158f59b8
children 10b3fb28c86b
files src/video/SDL_cursor.c
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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 ) {