From: hj kim Date: Mon, 19 Mar 2018 10:16:43 +0000 (+0900) Subject: Fix coverity issues X-Git-Tag: accepted/tizen/unified/20180321.060743^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a3bef03fb762ed3f7825ed0231e188991f30c72;p=platform%2Fcore%2Fapi%2Fmedia-content.git Fix coverity issues Change-Id: Id0f867452ca0210cda470c9d5c4f44f8388e6b01 --- diff --git a/src/media_content.c b/src/media_content.c index 616ef8a..2b53403 100755 --- a/src/media_content.c +++ b/src/media_content.c @@ -945,6 +945,8 @@ static int __media_content_create_attribute_handles(void) char *_attr_platform = NULL; char *_alias_attr_user = NULL; char *_alias_attr_platform = NULL; + attribute_s *_attr = NULL; + attribute_s *_alias_attr = NULL; ret = _media_filter_attribute_create(&g_attr_handle); media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); @@ -953,8 +955,8 @@ static int __media_content_create_attribute_handles(void) if (ret != MEDIA_CONTENT_ERROR_NONE) goto ERROR; - attribute_s *_attr = (attribute_s*)g_attr_handle; - attribute_s *_alias_attr = (attribute_s*)g_alias_attr_handle; + _attr = (attribute_s*)g_attr_handle; + _alias_attr = (attribute_s*)g_alias_attr_handle; count = sizeof(g_content_attrs_info) / sizeof((g_content_attrs_info)[0]); diff --git a/src/media_filter.c b/src/media_filter.c index bcdc68d..2893636 100755 --- a/src/media_filter.c +++ b/src/media_filter.c @@ -725,6 +725,8 @@ int _media_filter_attribute_generate(attribute_h attr, filter_h filter, char **g if (STRING_VALID(replace_str)) { SAFE_FREE(token->str); token->str = replace_str; + } else { + SAFE_FREE(replace_str); } } } @@ -819,6 +821,7 @@ int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, c SAFE_FREE(replace_str); } else { media_content_error("There is no matched db field for %s", token->str); + SAFE_FREE(replace_str); } } } @@ -898,6 +901,8 @@ int _media_filter_attribute_option_generate_with_full_query(attribute_h attr, fi if (STRING_VALID(replace_str)) { SAFE_FREE(token->str); token->str = replace_str; + } else { + SAFE_FREE(replace_str); } } } diff --git a/src/media_info.c b/src/media_info.c index 95266c9..bbe1f9f 100755 --- a/src/media_info.c +++ b/src/media_info.c @@ -2173,7 +2173,6 @@ int media_info_get_storage_id(media_info_h media, char **storage_id) *storage_id = NULL; ret = MEDIA_CONTENT_ERROR_DB_FAILED; } - ret = MEDIA_CONTENT_ERROR_NONE; } else { media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; diff --git a/test/media-content_test.c b/test/media-content_test.c index 8f35f0c..2dee86d 100755 --- a/test/media-content_test.c +++ b/test/media-content_test.c @@ -235,10 +235,14 @@ bool gallery_folder_list_cb(media_folder_h folder, void *user_data) bool gallery_media_item_cb(media_info_h media, void *user_data) { media_info_h new_media = NULL; - media_info_clone(&new_media, media); + int ret = MEDIA_CONTENT_ERROR_NONE; - GList **list = (GList**)user_data; - *list = g_list_append(*list, new_media); + ret = media_info_clone(&new_media, media); + + if (ret != MEDIA_CONTENT_ERROR_NONE) { + GList **list = (GList**)user_data; + *list = g_list_append(*list, new_media); + } return true; }