Coverity issue fix 29/173829/2 accepted/tizen/unified/20180330.060653 submit/tizen/20180328.052229
authorVikas Kumar Agrawal <vikas.ag@samsung.com>
Mon, 26 Mar 2018 07:51:52 +0000 (13:21 +0530)
committerVikas Kumar Agrawal <vikas.ag@samsung.com>
Mon, 26 Mar 2018 08:32:45 +0000 (14:02 +0530)
Change-Id: Ied801903f8297bc48e761db59d96c73090bac322

src/db.c
src/item.c
src/item_event.c
src/menu_screen.c [changed mode: 0755->0644]

index 2eba48dd77c7c1d66c2abcdd4a281c433fde4a83..70c3faee2ad344ee0a1557973224035d65bd0e13 100644 (file)
--- a/src/db.c
+++ b/src/db.c
@@ -72,6 +72,8 @@ HAPI menu_screen_error_e db_open(const char *db_file)
        res_path = app_get_data_path();
        snprintf(db_file_path, sizeof(db_file_path), "%s%s", res_path, db_file);
 
+       if (res_path)
+               free(res_path);
        retv_if(NULL == db_file, MENU_SCREEN_ERROR_INVALID_PARAMETER);
        if (db_info.db) {
                _D("db is already exist");
@@ -178,12 +180,12 @@ HAPI menu_screen_error_e db_next(stmt_h *handle)
 
        ret = sqlite3_step(handle->stmt);
        switch (ret) {
-               case SQLITE_ROW:
-                       return MENU_SCREEN_ERROR_OK;
-               case SQLITE_DONE:
-                       return MENU_SCREEN_ERROR_NO_DATA;
-               default:
-                       retv_with_dbmsg_if(1, MENU_SCREEN_ERROR_FAIL);
+       case SQLITE_ROW:
+               return MENU_SCREEN_ERROR_OK;
+       case SQLITE_DONE:
+               return MENU_SCREEN_ERROR_NO_DATA;
+       default:
+               retv_with_dbmsg_if(1, MENU_SCREEN_ERROR_FAIL);
        }
 }
 
@@ -245,7 +247,7 @@ HAPI menu_screen_error_e db_finalize(stmt_h *handle)
        retv_if(NULL == handle->stmt, MENU_SCREEN_ERROR_INVALID_PARAMETER);
 
        ret = sqlite3_finalize(handle->stmt);
-       if(ret != SQLITE_OK) {
+       if (ret != SQLITE_OK) {
                _E("Cannot finalize handle");
        }
        free(handle);
index 7dab7ea37375ab20b92aad32c5f108abbc409870..a8f8adba6735f462e17bcedd31569b4c7fb9dbb3 100644 (file)
@@ -80,7 +80,7 @@ HAPI void item_set_icon(Evas_Object *edje, char *icon, int sync)
                tmp = strdup(icon);
                if (tmp) {
                        evas_object_data_set(edje, STR_ATTRIBUTE_ICON, tmp);
-               }else {
+               } else {
                        _E("No more memory for allocating space \"%s\"", icon);
                }
        }
@@ -101,7 +101,7 @@ HAPI void item_set_name(Evas_Object *edje, char *name, int sync)
        int changed;
 
        tmp = evas_object_data_get(edje, STR_ATTRIBUTE_NAME);
-       if (!(tmp||name)) return;
+       if (!(tmp || name)) return;
        changed = (tmp && name) ? strcmp(name, tmp) : 1;
 
        if (!changed) {
@@ -114,7 +114,7 @@ HAPI void item_set_name(Evas_Object *edje, char *name, int sync)
                tmp = strdup(name);
                ret_if(NULL == tmp);
                evas_object_data_set(edje, STR_ATTRIBUTE_NAME, tmp);
-               if (edje_object_part_text_set(_EDJ(edje), "txt", tmp) == EINA_FALSE){
+               if (edje_object_part_text_set(_EDJ(edje), "txt", tmp) == EINA_FALSE) {
                        _E("Failed to set text on the part");
                }
                elm_object_signal_emit(edje, "text,on", "menu");
@@ -469,8 +469,7 @@ HAPI void item_unedit(Evas_Object *item)
 
        package = item_get_package(item);
        if (item_badge_is_registered(item)
-                       && item_badge_count(package) > 0)
-       {
+                       && item_badge_count(package) > 0) {
                edje_object_signal_emit(_EDJ(item), "badge,on", "menu");
        }
 }
@@ -538,8 +537,8 @@ HAPI menu_screen_error_e item_is_edje_icon(const char *icon)
        len = strlen(icon) - 1;
 
        while (len >= 0 && *ext && icon[len] == *ext) {
-               len --;
-               ext ++;
+               len--;
+               ext++;
        }
 
        return *ext ? MENU_SCREEN_ERROR_FAIL : MENU_SCREEN_ERROR_OK;
@@ -565,7 +564,7 @@ HAPI void item_update(Evas_Object *item, app_info_t *ai)
                        if (!ai->icon) _E("Critical! strdup error");
                }
 
-               if (ai->icon) {
+               if (ai->icon && 0 == access(ai->icon, R_OK)) {
                        FILE *fp;
                        fp = fopen(ai->icon, "rb");
                        if (fp) {
@@ -768,8 +767,7 @@ HAPI Evas_Object *item_create(Evas_Object *scroller, app_info_t* ai)
        item_update(item, ai);
        item_event_register(item);
        if (MENU_SCREEN_ERROR_OK !=
-                                       pkgmgr_item_list_append_item(ai->pkgid, ai->package, item))
-       {
+                                       pkgmgr_item_list_append_item(ai->pkgid, ai->package, item)) {
                _E("Cannot append an item into the item list");
        }
 
@@ -789,7 +787,7 @@ HAPI void item_destroy(Evas_Object *item)
        Evas_Object *pend_item;
        const char *icon_image_type;
        char *pkgid = NULL;
-       char *package= NULL;
+       char *package = NULL;
 
        ret_if(NULL == item);
 
@@ -799,8 +797,7 @@ HAPI void item_destroy(Evas_Object *item)
        if (pkgid
                && package
                && MENU_SCREEN_ERROR_OK !=
-                                       pkgmgr_item_list_remove_item(pkgid, package, item))
-       {
+                                       pkgmgr_item_list_remove_item(pkgid, package, item)) {
                _E("Cannot remove an item in the item list");
        }
 
@@ -921,19 +918,19 @@ HAPI void item_launch(Evas_Object *obj)
 
        if (app_control_set_app_id(app_control_handle, package) != APP_CONTROL_ERROR_NONE) {
                _E("Failed to set app id");
-               return;
+               goto ERROR;
        }
 
        if (is_shortcut && !shortcut_launch_package) {
                if (app_control_set_uri(app_control_handle, evas_object_data_get(item, "content_info")) != APP_CONTROL_ERROR_NONE) {
                        _E("Failed to set uri");
-                       return;
+                       goto ERROR;
                }
 
                if (app_control_send_launch_request(app_control_handle, NULL, NULL) != APP_CONTROL_ERROR_NONE) {
                        _E("Failed to send launch request");
                        layout_disable_block(layout);
-                       return;
+                       goto ERROR;
                } else {
                        _D("Sending launch request successed");
                        ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, NULL);
@@ -941,12 +938,19 @@ HAPI void item_launch(Evas_Object *obj)
        } else {
                if (app_control_send_launch_request(app_control_handle, NULL, NULL) != APP_CONTROL_ERROR_NONE) {
                        _E("Failed to send launch request");
-                       return;
+                       goto ERROR;
                }
 
                _T(package);
                ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, NULL);
        }
+
+       app_control_destroy(app_control_handle);
+       app_control_handle = NULL;
+
+ERROR:
+       if (app_control_handle)
+               app_control_destroy(app_control_handle);
 }
 
 
index 1210e25c2ba997109c0f5ccfe99c1db2a4d61611..a734fa0526126b2f4cad54b0cb368770cfa2ef26 100644 (file)
@@ -89,10 +89,6 @@ static void _item_up_cb(void *data, Evas_Object *obj, const char* emission, cons
        evas_object_color_set(icon_image, 255, 255, 255, 255);
 
        ret_if(NULL == item_event_info.pressed_item);
-       if (item != item_event_info.pressed_item) {
-               item_event_info.pressed_item = NULL;
-               return;
-       }
        item_event_info.pressed_item = NULL;
 }
 
old mode 100755 (executable)
new mode 100644 (file)
index e209c2c..dce0a85
@@ -500,22 +500,26 @@ static void _language_changed_cb(app_event_info_h event_info, void *data)
 
        count = page_scroller_count_page(scroller);
        page_max_app = (unsigned int) evas_object_data_get(scroller, "page_max_app");
-       for (i = 0; i < count; i ++) {
+       for (i = 0; i < count; i++) {
                page = page_scroller_get_page_at(scroller, i);
                if (!page) continue;
                if (mapbuf_is_enabled(page)) {
                        mapbuf_disable(page, 1);
                }
 
-               for (j = 0; j < page_max_app; j ++) {
+               for (j = 0; j < page_max_app; j++) {
                        app_info_h app_info = NULL;
                        char *name;
                        int ret;
+                       char *package;
 
                        item = page_get_item_at(page, j);
                        if (!item) continue;
 
-                       app_manager_get_app_info(item_get_package(item), &app_info);
+                       package = item_get_package(item);
+                       if (!package) continue;
+
+                       app_manager_get_app_info(package, &app_info);
 
                        ret = app_info_get_label(app_info, &name);
                        if (APP_MANAGER_ERROR_NONE != ret) {