efl_ui_pager: add missing conditions in pack before/after function
authorJaeun Choi <jaeun12.choi@samsung.com>
Wed, 23 Jan 2019 11:57:09 +0000 (20:57 +0900)
committerTaehyub Kim <taehyub.kim@samsung.com>
Thu, 31 Jan 2019 01:53:48 +0000 (10:53 +0900)
the functions should return if the 'existing' object is not in the content list

src/lib/elementary/efl_ui_pager.c

index c9df2f7317d61ae6ea5ebed6ffcdb774c06b5b5d..e89be997200d73e70c162630a41bf1f8b6bad725 100644 (file)
@@ -451,9 +451,9 @@ _efl_ui_pager_efl_pack_linear_pack_before(Eo *obj EINA_UNUSED,
 {
    if (!EINA_DBL_EQ(pd->curr.pos, 0.0)) return EINA_FALSE;
 
-   int index;
+   int index = eina_list_data_idx(pd->content_list, (void *)existing);
+   if (index == -1) return EINA_FALSE;
 
-   index = eina_list_data_idx(pd->content_list, (void *)existing);
    pd->content_list = eina_list_prepend_relative(pd->content_list, subobj, existing);
 
    pd->cnt += 1;
@@ -480,9 +480,9 @@ _efl_ui_pager_efl_pack_linear_pack_after(Eo *obj EINA_UNUSED,
 {
    if (!EINA_DBL_EQ(pd->curr.pos, 0.0)) return EINA_FALSE;
 
-   int index;
+   int index = eina_list_data_idx(pd->content_list, (void *)existing);
+   if (index == -1) return EINA_FALSE;
 
-   index = eina_list_data_idx(pd->content_list, (void *)existing);
    pd->content_list = eina_list_append_relative(pd->content_list, subobj, existing);
 
    pd->cnt += 1;