Skip to content

Commit

Permalink
Prevent division-by-zero in WarpMouse if surface's pitch is zero (a G…
Browse files Browse the repository at this point in the history
…L surface?).
  • Loading branch information
icculus committed Oct 30, 2005
1 parent 8cc81e3 commit 57632d9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/video/SDL_cursor.c
Expand Up @@ -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 ) {
Expand Down

0 comments on commit 57632d9

Please sign in to comment.