summaryrefslogtreecommitdiff
path: root/hw/xfree86/common/xf86cmap.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2010-01-26 22:25:04 -0800
committerKeith Packard <keithp@keithp.com>2010-01-27 14:18:20 -0800
commit003829072853546abd973266fe9b24d803f4f5cb (patch)
tree17aa12b2e138b8fbe1747dc452e4c6b1196867e7 /hw/xfree86/common/xf86cmap.c
parent19d03d4f49e08442f58cf02240e3e6bab04633d2 (diff)
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>
Diffstat (limited to 'hw/xfree86/common/xf86cmap.c')
-rw-r--r--hw/xfree86/common/xf86cmap.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index 08f557ccd..edd5ae9b0 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -1004,12 +1004,14 @@ xf86ChangeGammaRamp(
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
- if (crtc->gammaSize != size)
- return BadValue;
+ if (crtc) {
+ if (crtc->gammaSize != size)
+ return BadValue;
- RRCrtcGammaSet(crtc, red, green, blue);
+ RRCrtcGammaSet(crtc, red, green, blue);
- return Success;
+ return Success;
+ }
}
if(CMapScreenKey == NULL)
@@ -1077,7 +1079,8 @@ xf86GetGammaRampSize(ScreenPtr pScreen)
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
- return crtc->gammaSize;
+ if (crtc)
+ return crtc->gammaSize;
}
if(CMapScreenKey == NULL) return 0;
@@ -1106,17 +1109,19 @@ xf86GetGammaRamp(
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
- if (crtc->gammaSize < size)
- return BadValue;
+ if (crtc) {
+ if (crtc->gammaSize < size)
+ return BadValue;
- if (!RRCrtcGammaGet(crtc))
- return BadImplementation;
+ if (!RRCrtcGammaGet(crtc))
+ return BadImplementation;
- memcpy(red, crtc->gammaRed, size * sizeof(*red));
- memcpy(green, crtc->gammaGreen, size * sizeof(*green));
- memcpy(blue, crtc->gammaBlue, size * sizeof(*blue));
+ memcpy(red, crtc->gammaRed, size * sizeof(*red));
+ memcpy(green, crtc->gammaGreen, size * sizeof(*green));
+ memcpy(blue, crtc->gammaBlue, size * sizeof(*blue));
- return Success;
+ return Success;
+ }
}
if(CMapScreenKey == NULL)