Fix coverity issues 65/173065/2 accepted/tizen/unified/20180321.060743 submit/tizen/20180320.040253
authorhj kim <backto.kim@samsung.com>
Mon, 19 Mar 2018 10:16:43 +0000 (19:16 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Tue, 20 Mar 2018 00:12:09 +0000 (00:12 +0000)
Change-Id: Id0f867452ca0210cda470c9d5c4f44f8388e6b01

src/media_content.c
src/media_filter.c
src/media_info.c
test/media-content_test.c

index 616ef8a..2b53403 100755 (executable)
@@ -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]);
 
index bcdc68d..2893636 100755 (executable)
@@ -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);
                                }
                        }
                }
index 95266c9..bbe1f9f 100755 (executable)
@@ -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;
index 8f35f0c..2dee86d 100755 (executable)
@@ -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;
 }