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

Kristian Høgsberg hoegsberg at gmail.com
Tue May 28 12:35:41 PDT 2013


On Tue, May 28, 2013 at 12:32:50AM +0900, Mun, Gwan-gyeong wrote:
> When exiting, this patch fixes segmentation fault.

Thanks again.  This time I also added a few test cases to catch these
"no config" cases that I normally don't hit.

Kristian

> ---
> From: Mun Gwan-gyeong <elongbug at gmail.com>
> Date: Tue, 28 May 2013 00:20:04 +0900
> Subject: [PATCH] config-parser: Avoid null dereference when exiting. (case:
> weston starts without config file.)
> 
> backtrace:
> (gdb) bt
> #0 0xb7704424 in __kernel_vsyscall ()
> #1 0xb757ddde in raise (sig=5) at
> ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:42
> #2 <signal handler called>
> #3 weston_config_destroy (config=0x0) at config-parser.c:508
> #4 0xb75cbc0e in x11_destroy (ec=0x93506b0) at compositor-x11.c:1473
> #5 0x0804e0e9 in main (argc=1, argv=0xbffe5354) at compositor.c:3337
> ---
> shared/config-parser.c | 3 +++
> 1 file changed, 3 insertions(+)
> 
> diff --git a/shared/config-parser.c b/shared/config-parser.c
> index eec3e9e..1d88eed 100644
> --- a/shared/config-parser.c
> +++ b/shared/config-parser.c
> @@ -505,6 +505,9 @@ weston_config_destroy(struct weston_config *config)
> struct weston_config_section *s, *next_s;
> struct weston_config_entry *e, *next_e;
> 
> + if (config == NULL)
> + return;
> +
> wl_list_for_each_safe(s, next_s, &config->section_list, link) {
> wl_list_for_each_safe(e, next_e, &s->entry_list, link) {
> free(e->key);
> -- 
> 1.7.9.5
> 

> From 8543b9138b57f7b96d2137fef78b03d13ca0f412 Mon Sep 17 00:00:00 2001
> From: Mun Gwan-gyeong <elongbug at gmail.com>
> Date: Tue, 28 May 2013 00:20:04 +0900
> Subject: [PATCH] config-parser: Avoid null dereference when exiting. (case:
>  weston starts without config file.)
> 
> backtrace:
>  (gdb) bt
>  #0  0xb7704424 in __kernel_vsyscall ()
>  #1  0xb757ddde in raise (sig=5) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:42
>  #2  <signal handler called>
>  #3  weston_config_destroy (config=0x0) at config-parser.c:508
>  #4  0xb75cbc0e in x11_destroy (ec=0x93506b0) at compositor-x11.c:1473
>  #5  0x0804e0e9 in main (argc=1, argv=0xbffe5354) at compositor.c:3337
> ---
>  shared/config-parser.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/shared/config-parser.c b/shared/config-parser.c
> index eec3e9e..1d88eed 100644
> --- a/shared/config-parser.c
> +++ b/shared/config-parser.c
> @@ -505,6 +505,9 @@ weston_config_destroy(struct weston_config *config)
>  	struct weston_config_section *s, *next_s;
>  	struct weston_config_entry *e, *next_e;
>  
> +	if (config == NULL)
> +		return;
> +
>  	wl_list_for_each_safe(s, next_s, &config->section_list, link) {
>  		wl_list_for_each_safe(e, next_e, &s->entry_list, link) {
>  			free(e->key);
> -- 
> 1.7.9.5
> 

> _______________________________________________
> 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