From 37c35c747e728d482721d9f3c31dc43a3f2eb33f Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 21 Sep 2017 16:03:05 +0900 Subject: [PATCH] powerkey: fix memory leak Change-Id: I609f1fd71c2728bb3bf6a7d347164107a703ef9d Signed-off-by: lokilee73 --- src/powerkey/powerkey-wearable.c | 41 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 21 deletions(-) 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) -- 2.7.4