From 89c3dfe41e3a17a4f27b20e23623dc5777670feb Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 29 Nov 2007 19:57:24 +1100 Subject: [PATCH] modes: use xf86RandR12Index to stop illegal access xf86RandR12Index set to -1, and if initialised it gets 0 or higher. This allows the server to start with xinerama turned on with only one head --- hw/xfree86/modes/xf86RandR12.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index 8fbb877b1..bb7f94581 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -59,7 +59,7 @@ static Bool xf86RandR12Init12 (ScreenPtr pScreen); static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen); #endif -static int xf86RandR12Index; +static int xf86RandR12Index = -1; static int xf86RandR12Generation; #define XF86RANDRINFO(p) \ @@ -340,10 +340,12 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen, PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen); Bool ret = FALSE; - if (randrp->virtualX == -1 || randrp->virtualY == -1) - { - randrp->virtualX = pScrn->virtualX; - randrp->virtualY = pScrn->virtualY; + if (xf86RandR12Index != -1) { + if (randrp->virtualX == -1 || randrp->virtualY == -1) + { + randrp->virtualX = pScrn->virtualX; + randrp->virtualY = pScrn->virtualY; + } } if (pRoot && pScrn->vtSema) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, FALSE); @@ -366,7 +368,7 @@ finish: if (pRoot && pScrn->vtSema) (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE); #if RANDR_12_INTERFACE - if (WindowTable[pScreen->myNum] && ret) + if ((xf86RandR12Index != -1) && WindowTable[pScreen->myNum] && ret) RRScreenSizeNotify (pScreen); #endif return ret; @@ -466,6 +468,9 @@ xf86RandR12CreateScreenResources (ScreenPtr pScreen) mmHeight); } + if (xf86RandR12Index == -1) + return TRUE; + if (randrp->virtualX == -1 || randrp->virtualY == -1) { randrp->virtualX = pScrn->virtualX; @@ -533,15 +538,17 @@ xf86RandR12Init (ScreenPtr pScreen) _X_EXPORT void xf86RandR12SetRotations (ScreenPtr pScreen, Rotation rotations) { - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); + XF86RandRInfoPtr randrp; #if RANDR_12_INTERFACE ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; int c; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); #endif - if (!xf86RandR12Index) + + if (xf86RandR12Index == -1) return; + randrp = XF86RANDRINFO(pScreen); #if RANDR_12_INTERFACE for (c = 0; c < config->num_crtc; c++) { xf86CrtcPtr crtc = config->crtc[c]; @@ -1066,11 +1073,10 @@ static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen) { int c; - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - if (!xf86RandR12Index) + if (xf86RandR12Index == -1) return TRUE; for (c = 0; c < config->num_crtc; c++) @@ -1091,11 +1097,11 @@ xf86RandR12TellChanged (ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); - XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); int c; - if (!xf86RandR12Index) + if (xf86RandR12Index == -1) return; + xf86RandR12SetInfo12 (pScreen); for (c = 0; c < config->num_crtc; c++) xf86RandR12CrtcNotify (config->crtc[c]->randr_crtc);