From c8de7275f50933cf1a212fafdc0029e64b7585ca Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Wed, 3 Jun 2020 11:30:49 +0900 Subject: [PATCH] Fix memory leak Fix memory leak for below: https://review.tizen.org/gerrit/c/platform/core/multimedia/libmedia-service/+/235209 Change-Id: I1c53f8d7885b82a22d77c763dbad9797726f3972 Signed-off-by: Minje Ahn --- src/common/media-svc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/common/media-svc.c b/src/common/media-svc.c index 60aab6b..484f289 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -529,22 +529,25 @@ int media_svc_refresh_item(sqlite3 *handle, bool is_direct, const char *storage_ ret = _media_svc_update_item_with_data(is_direct, &content_info, uid); if (ret == MS_MEDIA_ERR_NONE) { - /* Except scanner case */ - if (!is_direct) { - media_svc_debug("Update is successful. Sending noti for this"); - _media_svc_publish_noti(MS_MEDIA_ITEM_UPDATE, content_info.path, noti_item->media_type, noti_item->media_uuid, noti_item->mime_type); - } else { + if (is_direct) { /* To avoid over-occupying memory, update per BATCH_ITEM_COUNT_MAX. */ if (++g_media_svc_cur_data_cnt == BATCH_ITEM_COUNT_MAX) { ret = _media_svc_list_query_do(MEDIA_SVC_QUERY_SCANNER, uid); - media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info); + if (ret != MS_MEDIA_ERR_NONE) + goto QUERY_ERROR; + g_media_svc_cur_data_cnt = 0; } + } else { + /* Except scanner case */ + media_svc_debug("Update is successful. Sending noti for this"); + _media_svc_publish_noti(MS_MEDIA_ITEM_UPDATE, content_info.path, noti_item->media_type, noti_item->media_uuid, noti_item->mime_type); } } else { media_svc_error("_media_svc_update_item_with_data failed : %d", ret); } +QUERY_ERROR: _media_svc_destroy_content_info(&content_info); _media_svc_destroy_noti_item(noti_item); -- 2.7.4