[PATCH] weston: Fix memleak issue in compositor.c

Srivardhan sri.hebbar at samsung.com
Mon Jun 2 23:02:44 PDT 2014


Hi,

Has someone looked into reviewing this patch? May I know if it requires any
change?

Thank-you,
Hebbar

> -----Original Message-----
> From: wayland-devel [mailto:wayland-devel-
> bounces at lists.freedesktop.org] On Behalf Of Srivardhan Hebbar
> Sent: Tuesday, May 27, 2014 2:31 PM
> To: wayland-devel at lists.freedesktop.org
> Cc: sri.hebbar at samsung.com
> Subject: [PATCH] weston: Fix memleak issue in compositor.c
> 
> This fix is upon "Hardening <rdp.effort at gmail.com>" patch. [PATCH 2/2]
> Handle OOM with signal events.
> 
> Signed-off-by: Srivardhan Hebbar <sri.hebbar at samsung.com>
> ---
>  src/compositor.c |   23 +++++++++++++++++------
>  1 file changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/src/compositor.c b/src/compositor.c index 574db2d..f233101
> 100644
> --- a/src/compositor.c
> +++ b/src/compositor.c
> @@ -4207,6 +4207,11 @@ int main(int argc, char *argv[])
>  	signals[3] = wl_event_loop_add_signal(loop, SIGCHLD,
> sigchld_handler,
>  					      NULL);
> 
> +	if (!signals[0] || !signals[1] || !signals[2] || !signals[3]) {
> +		ret = EXIT_FAILURE;
> +		goto out_signals;
> +	}
> +
>  	if (noconfig == 0)
>  		config = weston_config_parse("weston.ini");
>  	if (config != NULL) {
> @@ -4234,13 +4239,16 @@ int main(int argc, char *argv[])
> 
>  	backend_init = weston_load_module(backend, "backend_init");
>  	free(backend);
> -	if (!backend_init)
> -		exit(EXIT_FAILURE);
> +	if (!backend_init) {
> +		ret = EXIT_FAILURE;
> +		goto out_signals;
> +	}
> 
>  	ec = backend_init(display, &argc, argv, config);
>  	if (ec == NULL) {
>  		weston_log("fatal: failed to create compositor\n");
> -		exit(EXIT_FAILURE);
> +		ret = EXIT_FAILURE;
> +		goto out_signals;
>  	}
> 
>  	catch_signals();
> @@ -4321,12 +4329,15 @@ int main(int argc, char *argv[])
> 
>  	wl_signal_emit(&ec->destroy_signal, ec);
> 
> -	for (i = ARRAY_LENGTH(signals); i;)
> -		wl_event_source_remove(signals[--i]);
> -
>  	weston_compositor_xkb_destroy(ec);
> 
>  	ec->destroy(ec);
> +
> +out_signals:
> +	for (i = ARRAY_LENGTH(signals) - 1; i >= 0; i--)
> +		if (signals[i])
> +			wl_event_source_remove(signals[i]);
> +
>  	wl_display_destroy(display);
> 
>  	weston_log_file_close();
> --
> 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