efl_ui_stack: Fix dereference null return value
authorChristopher Michael <cp.michael@samsung.com>
Tue, 12 Mar 2019 14:22:26 +0000 (10:22 -0400)
committerYeongjong Lee <yj34.lee@samsung.com>
Tue, 2 Apr 2019 03:45:17 +0000 (12:45 +0900)
Coverity reports that efl_data_scope_safe_get returns NULL here (273
out of 281 times). _end_anim dereferences pd directly, so we should
check for a valid 'pd' before calling _end_anim function.

Fixes Coverity CID1399082

@fix

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D8315

src/lib/elementary/efl_ui_stack.c

index 76b59c1..fed3e08 100644 (file)
@@ -124,6 +124,8 @@ _hide_anim_ended_cb(void *data, const Efl_Event *event EINA_UNUSED)
    Efl_Ui_Stack_Data *pd = efl_data_scope_safe_get(data, EFL_UI_STACK_CLASS);
    Efl_Canvas_Object *content;
 
+   EINA_SAFETY_ON_NULL_RETURN(pd);
+
    content = _end_anim(pd->hide_td);
    pd->hide_td = NULL;
    efl_gfx_entity_visible_set(content, EINA_FALSE);
@@ -136,6 +138,8 @@ _show_anim_ended_cb(void *data, const Efl_Event *event EINA_UNUSED)
    Efl_Ui_Stack_Data *pd = efl_data_scope_safe_get(data, EFL_UI_STACK_CLASS);
    Efl_Canvas_Object *content;
 
+   EINA_SAFETY_ON_NULL_RETURN(pd);
+
    content = _end_anim(pd->show_td);
    pd->show_td = NULL;
    //Activated Event