[PATCH][weston 1/3] ivi-layout-transition: Fix potential leak of memory pointed to by transition

Bryce Harrington bryce at osg.samsung.com
Wed Sep 23 17:06:25 PDT 2015


On Wed, Sep 23, 2015 at 10:33:21AM -0300, Lucas Tanure wrote:
> Free transition in ivi_layout_transition_fade_layer if we fail to
> allocate memory for data
> 
> Signed-off-by: Lucas Tanure <tanure at linux.com>

Don't forget spaces after keywords.  I.e. "if (" instead of "if("

I locally fixed that code style issue, as well as the missing semicolon
on the third patch.  Then since the three patches all have the same
title, and are each basically just one-liners, I squashed the whole
collection into one commit.

commit c8dcd16b01ea0f5ac8f32ee18374b2ca2694dd6c
Author:     Lucas Tanure <tanure at linux.com>
AuthorDate: Wed Sep 23 10:33:21 2015 -0300
Commit:     Bryce Harrington <bryce at osg.samsung.com>
CommitDate: Wed Sep 23 17:02:28 2015 -0700

    ivi-layout-transition: Fix potential leak of memory pointed to by transition

    Several fixes to handle invalid transition objects:

    1. Free transition in ivi_layout_transition_fade_layer if we fail to
       allocate memory for data

    2. Check if transition is not null and if layout_transition_register was
       ok before return, if not, free transition

    3. Destroy transition if layout_transition_register was not ok, we can't
       just free transition, we need to call layout_transition_destroy in
       order to free private_data from transition

    Signed-off-by: Lucas Tanure <tanure at linux.com>
    Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>

And pushed to trunk:

To ssh://git.freedesktop.org/git/wayland/weston
   ae5df83..c8dcd16  master -> master


> ---
>  ivi-shell/ivi-layout-transition.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/ivi-shell/ivi-layout-transition.c b/ivi-shell/ivi-layout-transition.c
> index 150e301..716dd70 100644
> --- a/ivi-shell/ivi-layout-transition.c
> +++ b/ivi-shell/ivi-layout-transition.c
> @@ -850,6 +850,7 @@ ivi_layout_transition_fade_layer(
>  	data = malloc(sizeof(*data));
>  	if (data == NULL) {
>  		weston_log("%s: memory allocation fails\n", __func__);
> +		free(transition);
>  		return;
>  	}
>  
> -- 
> 2.5.3
> 
> _______________________________________________
> 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