powerkey: fix memory leak 33/151533/3 accepted/tizen/unified/20170922.065344 submit/tizen/20170921.080302
authorlokilee73 <changjoo.lee@samsung.com>
Thu, 21 Sep 2017 07:03:05 +0000 (16:03 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Thu, 21 Sep 2017 07:30:44 +0000 (16:30 +0900)
Change-Id: I609f1fd71c2728bb3bf6a7d347164107a703ef9d
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
src/powerkey/powerkey-wearable.c

index 1494316..5fef216 100755 (executable)
@@ -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)