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

Paulo Zanoni przanoni at gmail.com
Thu Dec 1 07:40:57 PST 2011


2011/12/1 Keith Packard <keithp at keithp.com>:
> @@ -852,6 +852,10 @@ OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
>
>                /* match files named *.conf */
>                num = scandir(dirpath, &list, ConfigFilter, alphasort);
> +               if (num < 0) {
> +                       num = 0;
> +                       list = NULL;
> +               }
>                found = AddConfigDirFiles(dirpath, list, num);
>                if (!found) {
>                        free(dirpath);

Well, that solution would depend on AddConfigDirFiles behaving nicely
when called with list=NULL and num=0, which, from a certain point of
view, goes against your first comment on my initial patch.

Anyway, I'd be happy with any of the 3 solutions, since they all fix the bug.

>
> --
> keith.packard at intel.com



-- 
Paulo Zanoni


More information about the xorg-devel mailing list