[PATCH] config-parser: Avoid null dereference when handling config-parser ( when weston starts without config file. )

Mun, Gwan-gyeong elongbug at gmail.com
Mon May 27 08:09:50 PDT 2013


This patch fixes segmentation fault when weston starts without config file.

---
>From ad383a1ed8efa3ee402825bb99676c22f6578a5c Mon Sep 17 00:00:00 2001
From: Mun Gwan-gyeong <elongbug at gmail.com>
Date: Tue, 28 May 2013 00:04:26 +0900
Subject: [PATCH] config-parser: Avoid null dereference when handling
 config-parser ( when weston starts without config file. )

backtrace:
 (gdb) bt
 #0  weston_config_next_section (config=0x0, section=0xbfb2b608, name=0xbfb2b618) at config-parser.c:485
 #1  0xb75b1371 in x11_compositor_create (config=0x1, argv=0xbfb2ba44, argc=<optimized out>, use_pixman=0, no_input=0, fullscreen=0, display=0xb75b55f9)
    at compositor-x11.c:1582
 #2  backend_init (display=0x8354490, argc=0xbfb2b9b0, argv=0xbfb2ba44, config=0x0) at compositor-x11.c:1674
 #3  0x0804df7b in main (argc=1, argv=0xbfb2ba44) at compositor.c:3289
---
 shared/config-parser.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/shared/config-parser.c b/shared/config-parser.c
index 7a19ea5..eec3e9e 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -481,6 +481,9 @@ weston_config_next_section(struct weston_config *config,
 			   struct weston_config_section **section,
 			   const char **name)
 {
+	if (config == NULL)
+		return 0;
+
 	if (*section == NULL)
 		*section = container_of(config->section_list.next,
 					struct weston_config_section, link);
-- 
1.7.9.5

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-config-parser-Avoid-null-dereference-when-handling-c.patch
Type: text/x-patch
Size: 1316 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20130528/34b08adf/attachment-0001.bin>


More information about the wayland-devel mailing list