seoz pushed a commit to branch elementary-1.9.

http://git.enlightenment.org/core/elementary.git/commit/?id=bdb21e1584fa7276059ef4671650c9968210933e

commit bdb21e1584fa7276059ef4671650c9968210933e
Author: Jaeun Choi <[email protected]>
Date:   Mon Mar 3 18:10:47 2014 +0900

    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
---
 src/lib/elm_diskselector.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/lib/elm_diskselector.c b/src/lib/elm_diskselector.c
index cf3c097..8a00fff 100644
--- a/src/lib/elm_diskselector.c
+++ b/src/lib/elm_diskselector.c
@@ -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;
-        else
-          sd->selected_item = eina_list_nth(sd->items, 1);
+             if (dit != it)
+               sd->selected_item = dit;
+             else
+               sd->selected_item = eina_list_nth(sd->items, 1);
 
-        _selected_item_indicate(sd->selected_item);
+             _selected_item_indicate(sd->selected_item);
+          }
+        else
+          sd->selected_item = NULL;
      }
 
    _item_del(it);

-- 


Reply via email to