Fix issue detected by static analysis tool 17/318117/1
authorInhong Han <inhong1.han@samsung.com>
Mon, 13 Jan 2025 07:10:01 +0000 (16:10 +0900)
committerInhong Han <inhong1.han@samsung.com>
Mon, 13 Jan 2025 07:38:45 +0000 (16:38 +0900)
Change-Id: I3f1b6b00665dfcd33eae64a89b3982a2c2746e12

server/stickerd_data_manager.c

index 7ab5a7f98e80db3fc29d7287cfb9fe238bdb2c89..15960cf305ccbe3dc42f7785a7f9ac8d1184c1fa 100644 (file)
@@ -958,8 +958,13 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_
                 goto free_memory;
 
             if (sticker_info->type == STICKER_URI_TYPE_LOCAL_PATH) {
+                char *old_uri = sticker_info->uri;
                 if (_check_file_exist(sticker_info->app_id, sticker_info->uri) == 0) {
                     sticker_info->uri = _convert_sticker_uri(sticker_info->uri, sticker_info->app_id);
+
+                    free(old_uri);
+                    old_uri = NULL;
+
                     if (!sticker_info->uri)
                         goto free_memory;
                 } else {
@@ -973,8 +978,13 @@ int stickerd_insert_sticker_info_by_json(GVariant *parameters, GVariant **reply_
 
             sticker_info->thumbnail = _get_string_from_object(info_object, "thumbnail");
             if (sticker_info->thumbnail && sticker_info->thumbnail[0] != '\0') {
+                char *old_thumbnail = sticker_info->thumbnail;
                 if (_check_file_exist(sticker_info->app_id, sticker_info->thumbnail) == 0) {
                     sticker_info->thumbnail = _convert_sticker_uri(sticker_info->thumbnail, sticker_info->app_id);
+
+                    free(old_thumbnail);
+                    old_thumbnail = NULL;
+
                     if (!sticker_info->thumbnail)
                         goto free_memory;
                 } else {