From 9a874a71a791c6110fd57b8a5c083f777a446d0f Mon Sep 17 00:00:00 2001 From: Egbert Eich Date: Tue, 4 Nov 2008 21:31:27 +0100 Subject: [PATCH] DDX/RandR: When positioning outputs assume width/height = 0 if no modes exist. When a user specifies the position of an output for which no modes exist (for whatever reason) assume that the width and height of this output is 0. The result will be the same as if this output isn't taken into consideration at all and thus should be sane. It will prevent a segfault when trying to determine the width and height of a non-existent mode. --- hw/xfree86/modes/xf86Crtc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index df47598aa..f072109de 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1185,10 +1185,12 @@ xf86InitialOutputPositions (ScrnInfoPtr scrn, DisplayModePtr *modes) output->initial_x += xf86ModeWidth (modes[or], relative->initial_rotation); break; case OPTION_ABOVE: - output->initial_y -= xf86ModeHeight (modes[o], output->initial_rotation); + if (modes[o]) + output->initial_y -= xf86ModeHeight (modes[o], output->initial_rotation); break; case OPTION_LEFT_OF: - output->initial_x -= xf86ModeWidth (modes[o], output->initial_rotation); + if (modes[o]) + output->initial_x -= xf86ModeWidth (modes[o], output->initial_rotation); break; default: break;