[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#580043: xserver-xorg-core: "Xorg -configure" crashes (Segmentation fault)



Cyril Brulebois <kibi@debian.org> (04/05/2010):
> Anyway, I reproduced this bug just by installing -vmware, I'll try
> and look into it somewhen this week.

The attached patch (against master, but also current unstable package)
seems to just work for me. Comments in there should be pretty much
explaining in case anyone is interested in looking into what's
actually going on.

I'll probably contact upstream about that once I have another look at
it.

(Jordi, I've added you to the Cc since I merged your bug into that
other one.)

Mraw,
KiBi.
From 5c73ca65fb5dbce20f344f814b8942e04e9314cb Mon Sep 17 00:00:00 2001
From: Cyril Brulebois <kibi@debian.org>
Date: Wed, 5 May 2010 03:37:40 +0200
Subject: [PATCH] Prevent Xorg -configure from segfaulting.

Signed-off-by: Cyril Brulebois <kibi@debian.org>
---
 src/vmwaremodule.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/vmwaremodule.c b/src/vmwaremodule.c
index d6fcddb..4a19dc5 100644
--- a/src/vmwaremodule.c
+++ b/src/vmwaremodule.c
@@ -151,7 +151,7 @@ vmware_chain_module(pointer opts)
     int vmware_devices;
     int matched;
     char *driver_name;
-    GDevPtr *gdevs;
+    GDevPtr *gdevs = NULL;
     GDevPtr gdev;
     int i;
 
@@ -172,9 +172,20 @@ vmware_chain_module(pointer opts)
 	matched = vmwlegacy_devices;
     }
 
-    for (i = 0; i < vmware_devices; i++) {
+    /* During autoconfiguration, xf86MatchDevice() can return 1 while
+       leaving the passed GDevPtr** untouched, leading the caller to
+       believe it got an 1-element array, which is just a lie.
+       Rule #3: Don't believe what you're told. Always double check.
+    */
+    if (gdevs == NULL) {
+	xf86DrvMsg(-1, X_INFO, "%s: Empty list of devices returned.\n",
+		   VMWARE_DRIVER_NAME);
+    } else {
+      for (i = 0; i < vmware_devices; i++) {
 	gdev = gdevs[i];
 	gdev->driver = driver_name;
+      }
+      /* That's used nowhere anyway?! */
     }
 
     xfree(gdevs);
-- 
1.7.1

Attachment: signature.asc
Description: Digital signature


Reply to: