From 05bcbadd130524694e11e372d54cb419cea566cc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 11 Jul 2006 14:05:38 -0700 Subject: [PATCH] Avoid NULL dereference if cursor position changes during a mode change. --- src/i830_cursor.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/i830_cursor.c b/src/i830_cursor.c index b3736490..2cb069cc 100644 --- a/src/i830_cursor.c +++ b/src/i830_cursor.c @@ -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;