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@linux.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
This commit is contained in:
parent
ae5df83f8e
commit
c8dcd16b01
|
@ -512,7 +512,7 @@ create_visibility_transition(struct ivi_layout_surface *surface,
|
|||
destroy_func,
|
||||
duration);
|
||||
|
||||
if(!layout_transition_register(transition))
|
||||
if (!layout_transition_register(transition))
|
||||
layout_transition_destroy(transition);
|
||||
}
|
||||
|
||||
|
@ -746,9 +746,10 @@ ivi_layout_transition_move_layer(struct ivi_layout_layer *layer,
|
|||
NULL, NULL,
|
||||
duration);
|
||||
|
||||
layout_transition_register(transition);
|
||||
if (transition && layout_transition_register(transition))
|
||||
return;
|
||||
|
||||
return;
|
||||
free(transition);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -850,6 +851,7 @@ ivi_layout_transition_fade_layer(
|
|||
data = malloc(sizeof(*data));
|
||||
if (data == NULL) {
|
||||
weston_log("%s: memory allocation fails\n", __func__);
|
||||
free(transition);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -871,7 +873,8 @@ ivi_layout_transition_fade_layer(
|
|||
data->end_alpha = end_alpha;
|
||||
data->destroy_func = destroy_func;
|
||||
|
||||
layout_transition_register(transition);
|
||||
if (!layout_transition_register(transition))
|
||||
layout_transition_destroy(transition);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue