From: Jihoon Kim Date: Mon, 22 Mar 2021 11:39:05 +0000 (+0900) Subject: Fix branch past initialize issue X-Git-Tag: accepted/tizen/unified/20210324.124243~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90e6316cb858f2d406c73cd5263749f2a0c82072;p=platform%2Fcore%2Fuifw%2Fcapi-ui-sticker.git Fix branch past initialize issue If the variable is used after the target, it will be uninitialized. A goto jumps past the initialization of a variable. Change-Id: If1faa93209af3328ae4dea4103533cc550fc1679 Signed-off-by: Jihoon Kim --- diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index 89f9b4f..1e8030c 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -404,6 +404,7 @@ int stickerd_dbus_init(void) static int _check_file_exist(const char *app_id, const char *path) { int ret = 0; + int path_len = 0; package_info_h package_info = NULL; char *app_path = NULL; char *file_path = NULL; @@ -427,7 +428,7 @@ static int _check_file_exist(const char *app_id, const char *path) goto cleanup; } - int path_len = strlen(app_path) + strlen(path) + 2; + path_len = strlen(app_path) + strlen(path) + 2; file_path = (char *)calloc(path_len, sizeof(char)); if (!file_path) { LOGE("Failed to alloc memory"); @@ -862,6 +863,9 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_ int arr_len = 0; int keyword_arr_len = 0; + JsonNode *root = NULL; + JsonObject *root_obj = NULL; + *reply_body = g_variant_new("()"); if (*reply_body == NULL) { LOGE("Failed to create reply_body"); @@ -885,14 +889,14 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_ goto cleanup; } - JsonNode *root = json_parser_get_root(parser); + root = json_parser_get_root(parser); if (root == NULL) { LOGE("failed to get root"); ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; goto cleanup; } - JsonObject *root_obj = json_node_get_object(root); + root_obj = json_node_get_object(root); if (root_obj == NULL) { LOGE("failed to get object"); ret = STICKERD_SERVER_ERROR_OPERATION_FAILED; diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index 2775cea..dfa84c9 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -496,8 +496,11 @@ cleanup: int stickerd_db_delete_sticker_info(int record_id) { int ret; + int uri_type = 0; sqlite3 *db = NULL; sqlite3_stmt *stmt = NULL; + const unsigned char *uri = NULL; + const unsigned char *thumbnail = NULL; db = _db_open(); if (!db) @@ -517,9 +520,9 @@ int stickerd_db_delete_sticker_info(int record_id) goto cleanup; } - int uri_type = sqlite3_column_int(stmt, 0); - const unsigned char *uri = sqlite3_column_text(stmt, 1); - const unsigned char *thumbnail = sqlite3_column_text(stmt, 2); + uri_type = sqlite3_column_int(stmt, 0); + uri = sqlite3_column_text(stmt, 1); + thumbnail = sqlite3_column_text(stmt, 2); if (uri_type == 1 && unlink((const char *)uri) == -1) LOGE("fail to delete sticker file"); @@ -565,6 +568,9 @@ int stickerd_db_delete_sticker_info_by_uri(char *uri) sqlite3 *db = NULL; sqlite3_stmt *stmt = NULL; + int uri_type = 0; + const unsigned char *thumbnail = NULL; + db = _db_open(); if (!db) return STICKERD_SERVER_ERROR_DB_FAILED; @@ -583,8 +589,8 @@ int stickerd_db_delete_sticker_info_by_uri(char *uri) goto cleanup; } - int uri_type = sqlite3_column_int(stmt, 0); - const unsigned char *thumbnail = sqlite3_column_text(stmt, 1); + uri_type = sqlite3_column_int(stmt, 0); + thumbnail = sqlite3_column_text(stmt, 1); if (uri_type == 1 && unlink((const char *)uri) == -1) LOGE("fail to delete sticker file"); @@ -702,6 +708,13 @@ int stickerd_db_get_sticker_info_by_record_id(int record_id, sticker_info_db *st sqlite3 *db = NULL; sqlite3_stmt *stmt = NULL; + const unsigned char *tmp_app_id = NULL; + const unsigned char *tmp_uri = NULL; + const unsigned char *tmp_thumbnail = NULL; + const unsigned char *tmp_description = NULL; + const unsigned char *tmp_group = NULL; + const unsigned char *tmp_date = NULL; + db = _db_open(); if (!db) return STICKERD_SERVER_ERROR_DB_FAILED; @@ -720,7 +733,7 @@ int stickerd_db_get_sticker_info_by_record_id(int record_id, sticker_info_db *st goto cleanup; } - const unsigned char *tmp_app_id = sqlite3_column_text(stmt, 1); + tmp_app_id = sqlite3_column_text(stmt, 1); if (tmp_app_id) { sticker_info->app_id = strdup((const char *)tmp_app_id); } else { @@ -730,23 +743,23 @@ int stickerd_db_get_sticker_info_by_record_id(int record_id, sticker_info_db *st sticker_info->type = sqlite3_column_int(stmt, 2); - const unsigned char *tmp_uri = sqlite3_column_text(stmt, 3); + tmp_uri = sqlite3_column_text(stmt, 3); if (tmp_uri) sticker_info->uri = strdup((const char *)tmp_uri); - const unsigned char *tmp_thumbnail = sqlite3_column_text(stmt, 4); + tmp_thumbnail = sqlite3_column_text(stmt, 4); if (tmp_thumbnail) sticker_info->thumbnail = strdup((const char *)tmp_thumbnail); - const unsigned char *tmp_description = sqlite3_column_text(stmt, 5); + tmp_description = sqlite3_column_text(stmt, 5); if (tmp_description) sticker_info->description = strdup((const char *)tmp_description); - const unsigned char *tmp_group = sqlite3_column_text(stmt, 6); + tmp_group = sqlite3_column_text(stmt, 6); if (tmp_group) sticker_info->group = strdup((const char *)tmp_group); - const unsigned char *tmp_date = sqlite3_column_text(stmt, 7); + tmp_date = sqlite3_column_text(stmt, 7); if (tmp_date) sticker_info->date = strdup((const char *)tmp_date); @@ -1087,6 +1100,13 @@ int stickerd_db_get_sticker_info_by_uri(char *uri, sticker_info_db *sticker_info sqlite3 *db = NULL; sqlite3_stmt *stmt = NULL; + const unsigned char *tmp_app_id = NULL; + const unsigned char *tmp_uri = NULL; + const unsigned char *tmp_thumbnail = NULL; + const unsigned char *tmp_description = NULL; + const unsigned char *tmp_group = NULL; + const unsigned char *tmp_date = NULL; + db = _db_open(); if (!db) return STICKERD_SERVER_ERROR_DB_FAILED; @@ -1107,29 +1127,29 @@ int stickerd_db_get_sticker_info_by_uri(char *uri, sticker_info_db *sticker_info sticker_info->record_id = sqlite3_column_int(stmt, 0); - const unsigned char *tmp_app_id = sqlite3_column_text(stmt, 1); + tmp_app_id = sqlite3_column_text(stmt, 1); if (tmp_app_id) sticker_info->app_id = strdup((const char *)tmp_app_id); sticker_info->type = sqlite3_column_int(stmt, 2); - const unsigned char *tmp_uri = sqlite3_column_text(stmt, 3); + tmp_uri = sqlite3_column_text(stmt, 3); if (tmp_uri) sticker_info->uri = strdup((const char *)tmp_uri); - const unsigned char *tmp_thumbnail = sqlite3_column_text(stmt, 4); + tmp_thumbnail = sqlite3_column_text(stmt, 4); if (tmp_thumbnail) sticker_info->thumbnail = strdup((const char *)tmp_thumbnail); - const unsigned char *tmp_description = sqlite3_column_text(stmt, 5); + tmp_description = sqlite3_column_text(stmt, 5); if (tmp_description) sticker_info->description = strdup((const char *)tmp_description); - const unsigned char *tmp_group = sqlite3_column_text(stmt, 6); + tmp_group = sqlite3_column_text(stmt, 6); if (tmp_group) sticker_info->group = strdup((const char *)tmp_group); - const unsigned char *tmp_date = sqlite3_column_text(stmt, 7); + tmp_date = sqlite3_column_text(stmt, 7); if (tmp_date) sticker_info->date = strdup((const char *)tmp_date); diff --git a/sticker-parser/sticker-parser.c b/sticker-parser/sticker-parser.c index fe0c795..2eb877a 100644 --- a/sticker-parser/sticker-parser.c +++ b/sticker-parser/sticker-parser.c @@ -581,9 +581,14 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path char *uri_path = NULL; char *rel_thumbnail = NULL; JsonArray *keyword_arr = NULL; + JsonArray *allowlist_arr = NULL; + JsonArray *sticker_arr = NULL; int disp_type = 0; int keyword_arr_len = 0; + JsonNode *root = NULL; + JsonObject *root_obj = NULL; + parser = json_parser_new(); json_parser_load_from_file(parser, file_path, &err_msg); if (err_msg) { @@ -592,28 +597,28 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path goto cleanup; } - JsonNode *root = json_parser_get_root(parser); + root = json_parser_get_root(parser); if (root == NULL) { LOGE("failed to get root"); ret = 0; goto cleanup; } - JsonObject *root_obj = json_node_get_object(root); + root_obj = json_node_get_object(root); if (root_obj == NULL) { LOGE("failed to get object"); ret = 0; goto cleanup; } - JsonArray *allowlist_arr = json_object_get_array_member(root_obj, "whitelist"); + allowlist_arr = json_object_get_array_member(root_obj, "whitelist"); if (allowlist_arr != NULL) { for (int i = 0; i < json_array_get_length(allowlist_arr); i++) { __insert_sticker_allowlist_info(appid, json_array_get_string_element(allowlist_arr, i)); } } - JsonArray *sticker_arr = json_object_get_array_member(root_obj, "sticker"); + sticker_arr = json_object_get_array_member(root_obj, "sticker"); if (sticker_arr == NULL) { LOGE("failed to get array member"); ret = 0;