[PATCH] config: verify that the config file has been parsed

Kristian Høgsberg hoegsberg at gmail.com
Wed Sep 25 10:21:40 PDT 2013


On Wed, Sep 25, 2013 at 01:34:17PM +0100, Alex DAMIAN wrote:
> From: Alexandru DAMIAN <alexandru.damian at intel.com>
> 
> weston_config_parse may return NULL, leading
> to an ungraceful exit via SIGSEGV.
> 
> Adding a nice check that gracefully exits the compositor
> when the config.ini parsing failed.

Ah, the problem is actually that weston_config_get_full_path()
crashes.  Everything else is designed to work with a NULL config by
returning default values.  Weston should be able to start without a
config file.

I think we just want to log that we didn't find a config file if
weston_config_parse() returns NULL, but when it does return a config
we log the filename like we do now.

Kristian

> Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
> ---
>  src/compositor.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/compositor.c b/src/compositor.c
> index f619f82..9ba6e88 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -3489,6 +3489,10 @@ int main(int argc, char *argv[])
>  	}
>  
>  	config = weston_config_parse("weston.ini");
> +	if (config == NULL) {
> +		weston_log("Could not parse config file weston.ini");
> +		exit(EXIT_FAILURE);
> +	}
>  	weston_log("Using config file '%s'\n",
>  		   weston_config_get_full_path(config));
>  	section = weston_config_get_section(config, "core", NULL, NULL);
> -- 
> 1.8.1.2
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list