From: Jihoon Kim Date: Fri, 19 Mar 2021 08:36:34 +0000 (+0900) Subject: Fix branch past initialize issue X-Git-Tag: accepted/tizen/unified/20210321.225717~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7804d313914164dfc23f512fc37e57438e32e4e7;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: I41ecefd76dc71a6b194abd514c4231ac5597d986 Signed-off-by: Jihoon Kim --- diff --git a/client/src/sticker_data.c b/client/src/sticker_data.c index 85d407e..2b47114 100644 --- a/client/src/sticker_data.c +++ b/client/src/sticker_data.c @@ -36,6 +36,7 @@ static char* _make_absolute_path(const char *relative_path) package_info_h package_info = NULL; char *app_path = NULL; char *file_path = NULL; + int path_len = 0; ret = app_get_id(&app_id); if (ret != APP_ERROR_NONE) { @@ -58,7 +59,7 @@ static char* _make_absolute_path(const char *relative_path) goto cleanup; } - int path_len = strlen(app_path) + strlen(relative_path) + 2; + path_len = strlen(app_path) + strlen(relative_path) + 2; file_path = (char *)calloc(path_len, sizeof(char)); if (!file_path) { LOGE("failed to alloc memory"); //LCOV_EXCL_LINE diff --git a/server/stickerd_data_manager.c b/server/stickerd_data_manager.c index 9d9ef83..89f9b4f 100644 --- a/server/stickerd_data_manager.c +++ b/server/stickerd_data_manager.c @@ -857,6 +857,10 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_ GError* err_msg = NULL; GVariant *body = NULL; char *cmd = "send_insert_result"; + JsonArray *sticker_arr = NULL; + JsonArray *keyword_arr = NULL; + int arr_len = 0; + int keyword_arr_len = 0; *reply_body = g_variant_new("()"); if (*reply_body == NULL) { @@ -895,14 +899,14 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_ goto cleanup; } - 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 = STICKERD_SERVER_ERROR_OPERATION_FAILED; goto cleanup; } - int arr_len = json_array_get_length(sticker_arr); + arr_len = json_array_get_length(sticker_arr); for (int i = 0; i < arr_len; i++) { JsonObject *info_object = json_array_get_object_element(sticker_arr, i); if (info_object != NULL) { @@ -953,8 +957,8 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_ sticker_info->display_type = _get_int_from_object(info_object, "display_type"); - JsonArray *keyword_arr = json_object_get_array_member(info_object, "keyword"); - int keyword_arr_len = json_array_get_length(keyword_arr); + keyword_arr = json_object_get_array_member(info_object, "keyword"); + keyword_arr_len = json_array_get_length(keyword_arr); if (keyword_arr_len < 1) goto free_memory; diff --git a/server/stickerd_db_manager.c b/server/stickerd_db_manager.c index 37e3172..2775cea 100644 --- a/server/stickerd_db_manager.c +++ b/server/stickerd_db_manager.c @@ -1023,6 +1023,7 @@ int stickerd_db_insert_recent_sticker_info(int record_id) int ret; sqlite3 *db = NULL; sqlite3_stmt *stmt = NULL; + int result = 0; db = _db_open(); if (!db) @@ -1042,7 +1043,7 @@ int stickerd_db_insert_recent_sticker_info(int record_id) goto cleanup; } - int result = sqlite3_column_int(stmt, 0); + result = sqlite3_column_int(stmt, 0); sqlite3_finalize(stmt); stmt = NULL; diff --git a/sticker-parser/sticker-parser.c b/sticker-parser/sticker-parser.c index af9e3cc..fe0c795 100644 --- a/sticker-parser/sticker-parser.c +++ b/sticker-parser/sticker-parser.c @@ -579,6 +579,10 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path char *description = NULL; char *thumbnail_path = NULL; char *uri_path = NULL; + char *rel_thumbnail = NULL; + JsonArray *keyword_arr = NULL; + int disp_type = 0; + int keyword_arr_len = 0; parser = json_parser_new(); json_parser_load_from_file(parser, file_path, &err_msg); @@ -632,7 +636,7 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path if (!group) goto free_memory; - char *rel_thumbnail = __get_string_from_object(info_object, "thumbnail"); + rel_thumbnail = __get_string_from_object(info_object, "thumbnail"); if (rel_thumbnail) { if (rel_thumbnail[0] != '\0') { if (access(rel_thumbnail, F_OK) == 0) { @@ -660,10 +664,10 @@ static int __get_sticker_info_from_json(const char *appid, const char *file_path } description = __get_string_from_object(info_object, "description"); - int disp_type = __get_int_from_object(info_object, "display_type"); + disp_type = __get_int_from_object(info_object, "display_type"); - JsonArray *keyword_arr = json_object_get_array_member(info_object, "keyword"); - int keyword_arr_len = json_array_get_length(keyword_arr); + keyword_arr = json_object_get_array_member(info_object, "keyword"); + keyword_arr_len = json_array_get_length(keyword_arr); if (keyword_arr_len < 1) goto free_memory; @@ -929,6 +933,7 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * char *app_path = NULL; char *file_path = NULL; int ret = 0; + int path_len = 0; __db_init(); @@ -944,7 +949,7 @@ int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgid, const char *appid, GList * goto cleanup; } - int path_len = strlen(app_path) + strlen((char *)md->value) + 2; + path_len = strlen(app_path) + strlen((char *)md->value) + 2; file_path = (char *)calloc(path_len, sizeof(char)); if (!file_path) { LOGE("failed to alloc memory");