Set NULL after free 35/314535/2 accepted/tizen_9.0_unified accepted/tizen_unified accepted/tizen_unified_dev accepted/tizen_unified_toolchain accepted/tizen_unified_x accepted/tizen_unified_x_asan tizen tizen_9.0 accepted/tizen/9.0/unified/20241030.235155 accepted/tizen/unified/20240717.060536 accepted/tizen/unified/dev/20240718.035906 accepted/tizen/unified/toolchain/20240812.133113 accepted/tizen/unified/x/20240718.022859 accepted/tizen/unified/x/asan/20240813.231356 tizen_9.0_m2_release
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 15 Jul 2024 05:31:51 +0000 (14:31 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Mon, 15 Jul 2024 06:03:43 +0000 (15:03 +0900)
Change-Id: Ie97d67a234ed5b216e1afa3cc212321b8740b246
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/media-svc-util.c

index 6d97ba8..d2faaa4 100644 (file)
@@ -361,11 +361,9 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
        }
 
        if (!refresh) {
+               media_svc_retv_del_if(!storage_id, MS_MEDIA_ERR_INTERNAL, content_info);
                content_info->storage_uuid = g_strdup(storage_id);
-               media_svc_retv_del_if(content_info->storage_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
-
                content_info->media_uuid = __media_info_generate_uuid();
-               media_svc_retv_del_if(content_info->media_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
        }
 
        ret = __media_svc_get_mime_type(path, mime_type);
@@ -953,23 +951,23 @@ void _media_svc_destroy_content_info(media_svc_content_info_s *content_info)
        media_svc_retm_if(!content_info, "content info is NULL");
 
        /* Delete media_svc_content_info_s */
-       g_free(content_info->media_uuid);
-       g_free(content_info->path);
-       g_free(content_info->file_name);
-       g_free(content_info->mime_type);
-       g_free(content_info->thumbnail_path);
-       g_free(content_info->storage_uuid);
+       g_clear_pointer(&content_info->media_uuid, g_free);
+       g_clear_pointer(&content_info->path, g_free);
+       g_clear_pointer(&content_info->file_name, g_free);
+       g_clear_pointer(&content_info->mime_type, g_free);
+       g_clear_pointer(&content_info->thumbnail_path, g_free);
+       g_clear_pointer(&content_info->storage_uuid, g_free);
 
        /* Delete media_svc_content_meta_s */
-       g_free(content_info->media_meta.title);
-       g_free(content_info->media_meta.album);
-       g_free(content_info->media_meta.artist);
-       g_free(content_info->media_meta.album_artist);
-       g_free(content_info->media_meta.genre);
-       g_free(content_info->media_meta.year);
-       g_free(content_info->media_meta.recorded_date);
-       g_free(content_info->media_meta.track_num);
-       g_free(content_info->media_meta.datetaken);
+       g_clear_pointer(&content_info->media_meta.title, g_free);
+       g_clear_pointer(&content_info->media_meta.album, g_free);
+       g_clear_pointer(&content_info->media_meta.artist, g_free);
+       g_clear_pointer(&content_info->media_meta.album_artist, g_free);
+       g_clear_pointer(&content_info->media_meta.genre, g_free);
+       g_clear_pointer(&content_info->media_meta.year, g_free);
+       g_clear_pointer(&content_info->media_meta.recorded_date, g_free);
+       g_clear_pointer(&content_info->media_meta.track_num, g_free);
+       g_clear_pointer(&content_info->media_meta.datetaken, g_free);
 }
 
 int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_media_type_e media_type, uid_t uid)