diskselector: Fix segmentation fault

Summary:
The code was missing null check of sd->items list.
If the deleted item is the only item of the list,
sd->items becomes empty after removing it.
In that case, sd->selected_item should be set as NULL.
@fix
Fixes T988

Test Plan: execute diskselector_example_02 > click "Delete item" button 3 times

Reviewers: raster, seoz

Reviewed By: seoz

CC: seoz

Maniphest Tasks: T988

Differential Revision: https://phab.enlightenment.org/D595
This commit is contained in:
Jaeun Choi 2014-03-03 18:10:47 +09:00 committed by Daniel Juyung Seo
parent 7fb6ea14c5
commit 295630ed9d
1 changed files with 11 additions and 6 deletions

View File

@ -357,14 +357,19 @@ _item_del_pre_hook(Elm_Object_Item *item)
if (sd->selected_item == it)
{
dit = (Elm_Diskselector_Item *)eina_list_nth(sd->items, 0);
if (sd->items)
{
dit = (Elm_Diskselector_Item *)eina_list_nth(sd->items, 0);
if (dit != it)
sd->selected_item = dit;
if (dit != it)
sd->selected_item = dit;
else
sd->selected_item = eina_list_nth(sd->items, 1);
_selected_item_indicate(sd->selected_item);
}
else
sd->selected_item = eina_list_nth(sd->items, 1);
_selected_item_indicate(sd->selected_item);
sd->selected_item = NULL;
}
_item_del(it);