summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@herrb.eu>2016-07-31 12:13:03 +0200
committerAdam Jackson <ajax@redhat.com>2016-08-15 12:43:43 -0400
commit611b3b1d40f58035582480a3d7cfa77cb288cbc6 (patch)
tree91318167872d9fb42954c373013b68a36761816b
parent88820f1c7b66cbc98d3f19efca24c9f52410d9f9 (diff)
Autoconfig: Fix the loop adding dectected drivers to the list of screens
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@herrb.eu> Reviewed-by: Keith Packard <keithp@keithp.com>
-rw-r--r--hw/xfree86/common/xf86AutoConfig.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index e6ab900aa..940265144 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/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;
}