[PATCH v2 1/2] config: verify that the config file has been parsed

Alex DAMIAN alexandru.damian at intel.com
Wed Sep 25 05:48:48 PDT 2013


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.

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..bc4837f 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\n");
+		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



More information about the wayland-devel mailing list