[PATCH v2 xserver] Autoconfig: Fix the loop adding dectected drivers to the list of screens
Matthieu Herrb
matthieu at herrb.eu
Sun Jul 31 10:13:03 UTC 2016
This loop was written in a buggy style, causing a NULL driver ptr to be
passed to copyScreen(). copyScreen() only uses that to generate an
identifier string, so this is mostly harmless on systems that accept
NULL for asprintf() "%s" format. (the generated identifiers are off
by one wrt the driver names and the last one contains NULL.
For systems that don't accept NULL for '%s' this would cause a
segmentation fault when this code is used (no xorg.conf, but partial
config in xorg.conf.d for instance).
Signed-off-by: Matthieu Herrb <matthieu at herrb.eu>
---
hw/xfree86/common/xf86AutoConfig.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git hw/xfree86/common/xf86AutoConfig.c hw/xfree86/common/xf86AutoConfig.c
index e6ab900..9402651 100644
--- hw/xfree86/common/xf86AutoConfig.c
+++ hw/xfree86/common/xf86AutoConfig.c
@@ -389,8 +389,7 @@ autoConfigDevice(GDevPtr preconf_device)
/* for each other driver found, copy the first screen, insert it
* into the list of screens and set the driver */
- i = 0;
- while (i++ < num_matches) {
+ for (i = 1; i < num_matches; i++) {
if (!copyScreen(slp[0].screen, ptr, i, matches[i]))
return NULL;
}
--
2.8.4
More information about the xorg-devel
mailing list