From 4e6cbd323854709ae00c44108c93ab6596151de2 Mon Sep 17 00:00:00 2001 From: Zhenyu Wang Date: Wed, 8 Oct 2008 13:33:55 +0800 Subject: [PATCH] Check nextEnabledOutput()'s return in bestModeForAspect() In case no enabled outputs, we will reference wrong index of output array. (cherry picked from commit 56c615368c5a8e7acb0398434c2c68578626aa38) --- hw/xfree86/modes/xf86Crtc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 2080b23a1..1facf86e9 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -1903,7 +1903,8 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect) int o = -1, p; DisplayModePtr mode = NULL, test = NULL, match = NULL; - nextEnabledOutput(config, enabled, &o); + if (!nextEnabledOutput(config, enabled, &o)) + return NULL; while ((mode = nextAspectMode(config->output[o], mode, aspect))) { test = mode; for (p = o; nextEnabledOutput(config, enabled, &p); ) {