From: lokilee73 Date: Thu, 21 Sep 2017 07:03:05 +0000 (+0900) Subject: powerkey: fix memory leak X-Git-Tag: accepted/tizen/unified/20170922.065344^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=37c35c747e728d482721d9f3c31dc43a3f2eb33f;p=platform%2Fcore%2Fsystem%2Fsystem-popup.git powerkey: fix memory leak Change-Id: I609f1fd71c2728bb3bf6a7d347164107a703ef9d Signed-off-by: lokilee73 --- diff --git a/src/powerkey/powerkey-wearable.c b/src/powerkey/powerkey-wearable.c index 1494316..5fef216 100755 --- a/src/powerkey/powerkey-wearable.c +++ b/src/powerkey/powerkey-wearable.c @@ -357,14 +357,8 @@ create_list_view(appdata_s *application_info, const struct popup_ops *ops) int i; ad = (appdata_s *)application_info; - if (ad == NULL) { - elm_genlist_item_class_free(itc); - elm_genlist_item_class_free(ttc); - elm_genlist_item_class_free(utc); - elm_genlist_item_class_free(ptc); - - return; - } + if (ad == NULL) + goto out; genlist = elm_genlist_add(ad->nf); elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); @@ -399,23 +393,29 @@ create_list_view(appdata_s *application_info, const struct popup_ops *ops) i = 0; id = calloc(sizeof(Item_Data), 1); + if (id == NULL) + goto out; + id->index = i; id->item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_poweroff_cb, ops); i++; id = calloc(sizeof(Item_Data), 1); + if (id == NULL) + goto out; + id->index = i; id->item = elm_genlist_item_append(genlist, utc, id, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_airplane_cb, ops); elm_genlist_item_append(genlist, ptc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); + elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, ad->win); +out: elm_genlist_item_class_free(itc); elm_genlist_item_class_free(ttc); elm_genlist_item_class_free(utc); elm_genlist_item_class_free(ptc); - - nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); - elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, ad->win); } static void @@ -432,13 +432,8 @@ create_poweroff_view(appdata_s *application_info, const struct popup_ops *ops) int i; ad = (appdata_s *)application_info; - if (ad == NULL) { - elm_genlist_item_class_free(itc); - elm_genlist_item_class_free(ttc); - elm_genlist_item_class_free(ptc); - - return; - }; + if (ad == NULL) + goto out; genlist = elm_genlist_add(ad->nf); elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); @@ -465,17 +460,21 @@ create_poweroff_view(appdata_s *application_info, const struct popup_ops *ops) i = 0; id = calloc(sizeof(Item_Data), 1); + if (id == NULL) + goto out; + id->index = i; id->item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _gl_sel_poweroff_cb, ops); elm_genlist_item_append(genlist, ptc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); + elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, ad->win); + +out: elm_genlist_item_class_free(itc); elm_genlist_item_class_free(ttc); elm_genlist_item_class_free(ptc); - - nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty"); - elm_naviframe_item_pop_cb_set(nf_it, naviframe_pop_cb, ad->win); } static int powerkey_list(bundle *b, const struct popup_ops *ops)