Avoid segfaults in XF86VidMode GammaRamp functions if randr_crtc is NULL
Fixes crash when xscreensaver tries to use GammaRamp calls to fade out http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6915712 Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com> Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
19d03d4f49
commit
0038290728
|
@ -1004,12 +1004,14 @@ xf86ChangeGammaRamp(
|
||||||
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
|
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
|
||||||
RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
|
RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
|
||||||
|
|
||||||
if (crtc->gammaSize != size)
|
if (crtc) {
|
||||||
return BadValue;
|
if (crtc->gammaSize != size)
|
||||||
|
return BadValue;
|
||||||
|
|
||||||
RRCrtcGammaSet(crtc, red, green, blue);
|
RRCrtcGammaSet(crtc, red, green, blue);
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CMapScreenKey == NULL)
|
if(CMapScreenKey == NULL)
|
||||||
|
@ -1077,7 +1079,8 @@ xf86GetGammaRampSize(ScreenPtr pScreen)
|
||||||
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
|
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
|
||||||
RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
|
RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
|
||||||
|
|
||||||
return crtc->gammaSize;
|
if (crtc)
|
||||||
|
return crtc->gammaSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CMapScreenKey == NULL) return 0;
|
if(CMapScreenKey == NULL) return 0;
|
||||||
|
@ -1106,17 +1109,19 @@ xf86GetGammaRamp(
|
||||||
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
|
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
|
||||||
RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
|
RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
|
||||||
|
|
||||||
if (crtc->gammaSize < size)
|
if (crtc) {
|
||||||
return BadValue;
|
if (crtc->gammaSize < size)
|
||||||
|
return BadValue;
|
||||||
|
|
||||||
if (!RRCrtcGammaGet(crtc))
|
if (!RRCrtcGammaGet(crtc))
|
||||||
return BadImplementation;
|
return BadImplementation;
|
||||||
|
|
||||||
memcpy(red, crtc->gammaRed, size * sizeof(*red));
|
memcpy(red, crtc->gammaRed, size * sizeof(*red));
|
||||||
memcpy(green, crtc->gammaGreen, size * sizeof(*green));
|
memcpy(green, crtc->gammaGreen, size * sizeof(*green));
|
||||||
memcpy(blue, crtc->gammaBlue, size * sizeof(*blue));
|
memcpy(blue, crtc->gammaBlue, size * sizeof(*blue));
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CMapScreenKey == NULL)
|
if(CMapScreenKey == NULL)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user