Avoid NULL dereference if cursor position changes during a mode change.

This commit is contained in:
Eric Anholt 2006-07-11 14:05:38 -07:00
parent b65f18b05a
commit 05bcbadd13
1 changed files with 10 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* -*- c-basic-offset: 3 -*- */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@ -398,9 +398,15 @@ I830SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
x -= pScrn->frameX0;
y -= pScrn->frameY0;
/* Clamp the cursor position to the visible screen area */
if (x >= pScrn->currentMode->HDisplay) x = pScrn->currentMode->HDisplay - 1;
if (y >= pScrn->currentMode->VDisplay) y = pScrn->currentMode->VDisplay - 1;
/* Clamp the cursor position to the visible screen area. Ignore this if we
* are doing motion (with SilkenMouse) while the currentMode being changed.
*/
if (pScrn->currentMode != NULL) {
if (x >= pScrn->currentMode->HDisplay)
x = pScrn->currentMode->HDisplay - 1;
if (y >= pScrn->currentMode->VDisplay)
y = pScrn->currentMode->VDisplay - 1;
}
if (x <= -I810_CURSOR_X) x = -I810_CURSOR_X + 1;
if (y <= -I810_CURSOR_Y) y = -I810_CURSOR_Y + 1;