[TBT][tbtcoreapp][NonACR][Svace fix] 78/171078/1
authornibha2 <nibha.sharma@samsung.com>
Fri, 23 Feb 2018 08:40:47 +0000 (14:10 +0530)
committerAmritanshu Pandia <a.pandia1@samsung.com>
Mon, 26 Feb 2018 09:37:16 +0000 (09:37 +0000)
Change-Id: Icefd6c972e38c3904fd2b2d5abba8b1e88300238
Signed-off-by: nibha2 <nibha.sharma@samsung.com>
tbtcoreapp/src/view/tbt-cbhm-view.c

index f61d044232572f14d1e857daecd518e3387317ac..7dcb03bda40c86c2bd295179f7297e4b7e88ee33 100755 (executable)
@@ -117,6 +117,8 @@ static void _app_destroy_cb(void* this);
 static char *get_selection_type(cbhm_sel_type_e type)
 {
        char msg[40];
+       snprintf(msg, sizeof(msg), "Unknow Type");
+
        switch(type)
        {
        case CBHM_SEL_TYPE_TEXT :
@@ -134,8 +136,6 @@ static char *get_selection_type(cbhm_sel_type_e type)
        case CBHM_SEL_TYPE_IMAGE :
                snprintf(msg, sizeof(msg), "CBHM_SEL_TYPE_IMAGE");
                break;
-       default :
-               snprintf(msg, sizeof(msg), "Unknow Type");
        }
        return strdup(msg);
 }
@@ -210,13 +210,19 @@ static void _selection_type_set_cb(cbhm_sel_type_e type, void *data)
        char *hello_str;
        cbhm_view *this = (cbhm_view*) data;
        hello_str = (char *) malloc(50);
-       snprintf(hello_str, 50, "String : %s", get_selection_type(type));
+       char *selection_str = NULL;
+       selection_str = get_selection_type(type);
+
+       snprintf(hello_str, 50, "String : %s", selection_str);
 
        nRet = cbhm_selection_type_set(this->cbhm_handle, type);
-       RETM_IF(nRet != CBHM_ERROR_NONE, "cbhm_selection_type_set failed");
+       RETM_IF_CLEANUP(nRet != CBHM_ERROR_NONE, "cbhm_selection_type_set failed", SAFE_DELETE(hello_str); SAFE_DELETE(selection_str));
 
        nRet = cbhm_selection_set(this->cbhm_handle, type, hello_str, strlen(hello_str));
-       RETM_IF(nRet != CBHM_ERROR_NONE, "cbhm_selection_set failed");
+       RETM_IF_CLEANUP(nRet != CBHM_ERROR_NONE, "cbhm_selection_set failed", SAFE_DELETE(hello_str); SAFE_DELETE(selection_str));
+
+       SAFE_DELETE(selection_str);
+       SAFE_DELETE(hello_str);
 }
 
 
@@ -275,7 +281,7 @@ cbhm_view *cbhm_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item
        RETVM_IF(!this, NULL, "calloc failed");
 
        this->view = calloc(1, sizeof(common_view));
-       RETVM_IF(!this->view, NULL, "calloc failed");
+       RETVM_IF_CLEANUP(!this->view, NULL, "calloc failed", SAFE_DELETE(this));
 
        tbt_info->layout_group = "cbhm_test";
        tbt_info->layout_file = get_edje_path("cbhm_viewer.edj");
@@ -283,10 +289,9 @@ cbhm_view *cbhm_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item
        common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this);
 
 
-       RETVM_IF(NULL == this->view, NULL, "navi is null");
        nRet = cbhm_open_service(&(this->cbhm_handle));
-       RETVM_IF(nRet != CBHM_ERROR_NONE, NULL, "cbhm_open_service failed");
-       RETVM_IF(this->cbhm_handle == NULL, NULL, "cbhm_handle is NULL");
+       RETVM_IF_CLEANUP(nRet != CBHM_ERROR_NONE, NULL, "cbhm_open_service failed", SAFE_DELETE(this->view); SAFE_DELETE(this));
+       RETVM_IF_CLEANUP(this->cbhm_handle == NULL, NULL, "cbhm_handle is NULL", SAFE_DELETE(this->view); SAFE_DELETE(this));
 
        this->apptype = tbt_info->apptype;
        this->lat_label = ui_utils_label_add(this->view->layout, "???");
@@ -544,6 +549,8 @@ static void _show_cbhm_state_button_pressed_cb(void *data, Evas_Object *obj, voi
        int nRet = cbhm_state_get(this->cbhm_handle, &sType);
        RETM_IF(nRet != CBHM_ERROR_NONE, "cbhm_state_get failed");
 
+       ui_utils_label_set_text(this->lat_label, "Unknown State", "left");
+
        switch(sType)
        {
        case CBHM_STATE_NONE :
@@ -555,8 +562,6 @@ static void _show_cbhm_state_button_pressed_cb(void *data, Evas_Object *obj, voi
        case CBHM_STATE_HIDE :
                ui_utils_label_set_text(this->lat_label, "Clip Board State is : Hide", "left");
                break;
-       default :
-               ui_utils_label_set_text(this->lat_label, "Unknown State", "left");
        }
 }