[PATCH] Fix segfault when there's no config dir

przanoni at gmail.com przanoni at gmail.com
Mon Nov 28 08:09:40 PST 2011


From: Paulo Zanoni <paulo.r.zanoni at intel.com>

Also, call AddConfigDirFiles only if we found a file, protecting
ourselves from future changes to the AddConfigDirFiles function.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
---
 hw/xfree86/parser/scan.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index 9099227..54fa474 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -852,13 +852,16 @@ OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
 
 		/* match files named *.conf */
 		num = scandir(dirpath, &list, ConfigFilter, alphasort);
-		found = AddConfigDirFiles(dirpath, list, num);
+		if (num > 0)
+			found = AddConfigDirFiles(dirpath, list, num);
+		else
+			found = FALSE;
 		if (!found) {
 			free(dirpath);
 			dirpath = NULL;
 		}
-		while (num--)
-			free(list[num]);
+		while (num > 0)
+			free(list[--num]);
 		free(list);
 	}
 
-- 
1.7.7.3



More information about the xorg-devel mailing list