summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHosang Kim <hosang12.kim@samsung.com>2015-06-17 15:02:48 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-06-17 15:59:19 +0200
commitdbe8ca699a3ac55518d490f2aaad926cc5c86436 (patch)
tree065bf5664e2b3b996270fb084347d2c907225cc5
parentfb050ab650348a3bdd370c81f0b9ca911a904f9f (diff)
dayselector : add safety check for NULL pointer from _item_find()
Summary: It could make crash when _item_find() is failed. CID - 404129 CID - 402467 CID - 398714 CID - 390012 @fix Reviewers: raster, thiepha, woohyun, Hermet Differential Revision: https://phab.enlightenment.org/D2683 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/elm_dayselector.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/lib/elm_dayselector.c b/src/lib/elm_dayselector.c
index 1dbbd75ec..1c7e3b1b2 100644
--- a/src/lib/elm_dayselector.c
+++ b/src/lib/elm_dayselector.c
@@ -224,8 +224,9 @@ _elm_dayselector_elm_container_content_set(Eo *obj, Elm_Dayselector_Data *sd, co
224 int day; 224 int day;
225 char buf[1024]; 225 char buf[1024];
226 Elm_Dayselector_Item_Data *it = NULL; 226 Elm_Dayselector_Item_Data *it = NULL;
227 const char *type = elm_object_widget_type_get(content);
227 228
228 if (strcmp(elm_object_widget_type_get(content), "Elm_Check")) 229 if (type && strcmp(type, "Elm_Check"))
229 return EINA_FALSE; 230 return EINA_FALSE;
230 231
231 if (!item) return EINA_FALSE; 232 if (!item) return EINA_FALSE;
@@ -469,13 +470,25 @@ _elm_dayselector_eo_base_constructor(Eo *obj, Elm_Dayselector_Data *_pd EINA_UNU
469EOLIAN static void 470EOLIAN static void
470_elm_dayselector_day_selected_set(Eo *obj, Elm_Dayselector_Data *_pd EINA_UNUSED, Elm_Dayselector_Day day, Eina_Bool selected) 471_elm_dayselector_day_selected_set(Eo *obj, Elm_Dayselector_Data *_pd EINA_UNUSED, Elm_Dayselector_Day day, Eina_Bool selected)
471{ 472{
472 elm_check_state_set(VIEW(_item_find(obj, day)), selected); 473 Elm_Dayselector_Item_Data *it = _item_find(obj, day);
474 if (!it)
475 {
476 ERR("Failed to find item");
477 return;
478 }
479 elm_check_state_set(VIEW(it), selected);
473} 480}
474 481
475EOLIAN static Eina_Bool 482EOLIAN static Eina_Bool
476_elm_dayselector_day_selected_get(Eo *obj, Elm_Dayselector_Data *_pd EINA_UNUSED, Elm_Dayselector_Day day) 483_elm_dayselector_day_selected_get(Eo *obj, Elm_Dayselector_Data *_pd EINA_UNUSED, Elm_Dayselector_Day day)
477{ 484{
478 return elm_check_state_get(VIEW(_item_find(obj, day))); 485 Elm_Dayselector_Item_Data *it = _item_find(obj, day);
486 if (!it)
487 {
488 ERR("Failed to find item");
489 return EINA_FALSE;
490 }
491 return elm_check_state_get(VIEW(it));
479} 492}
480 493
481EOLIAN static void 494EOLIAN static void
@@ -555,6 +568,7 @@ _elm_dayselector_weekdays_names_set(Eo *obj, Elm_Dayselector_Data *sd, const cha
555 for (idx = 0; idx < ELM_DAYSELECTOR_MAX; idx++) 568 for (idx = 0; idx < ELM_DAYSELECTOR_MAX; idx++)
556 { 569 {
557 it = _item_find(obj, idx); 570 it = _item_find(obj, idx);
571 if (!it) continue;
558 572
559 if (sd->weekdays_names_set) 573 if (sd->weekdays_names_set)
560 elm_object_text_set(VIEW(it), weekdays[idx]); 574 elm_object_text_set(VIEW(it), weekdays[idx]);
@@ -578,6 +592,8 @@ _elm_dayselector_weekdays_names_get(Eo *obj, Elm_Dayselector_Data *sd EINA_UNUSE
578 for (idx = 0; idx < ELM_DAYSELECTOR_MAX; idx++) 592 for (idx = 0; idx < ELM_DAYSELECTOR_MAX; idx++)
579 { 593 {
580 it = _item_find(obj, idx); 594 it = _item_find(obj, idx);
595 if (!it) continue ;
596
581 weekday = elm_object_text_get(VIEW(it)); 597 weekday = elm_object_text_get(VIEW(it));
582 weekdays = eina_list_append(weekdays, eina_stringshare_add(weekday)); 598 weekdays = eina_list_append(weekdays, eina_stringshare_add(weekday));
583 } 599 }