From 275689eb6d5928fd00f4d90b92eee2707cf05203 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 30 Oct 2005 05:45:46 +0000 Subject: [PATCH] Prevent division-by-zero in WarpMouse if surface's pitch is zero (a GL surface?). --- src/video/SDL_cursor.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/video/SDL_cursor.c b/src/video/SDL_cursor.c index 2987db1aa..115fae111 100644 --- a/src/video/SDL_cursor.c +++ b/src/video/SDL_cursor.c @@ -303,9 +303,14 @@ void SDL_WarpMouse (Uint16 x, Uint16 y) } /* 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 ) {