From 017da2d1039837a49bf74c6c16d8a29a502bb52e 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?). --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401166 --- 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 ) {