Merge branch 'tizen_5.5' into tizen_5.5_tv 63/224463/2 tizen_5.5_tv submit/tizen_5.5_tv/20200212.032420
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 6 Feb 2020 05:39:30 +0000 (14:39 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Tue, 11 Feb 2020 00:44:10 +0000 (09:44 +0900)
Improve error type conversion function

Change-Id: Id75dbb50f97731b619ba2944027c01e42584cdef
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
(cherry picked from commit 988da7cf194ebc987f2f45cf7592688dba28a4a0)

Fix coverity issue

 - Resource leak

Change-Id: I3badedd37896e0fb8352be42be9f4b153e74f6b7
(cherry picked from commit bc66982deb57e773bac962fc795bbb249b5416b4)

packaging/capi-media-thumbnail-util.spec
src/thumbnail_util.c
test/thumbnail_util_test.c

index 3404f272fcb619319040ebf940ca49d0f8757df1..dac4aa01f47724869f653ef6c647ecfbee138f9e 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-thumbnail-util
 Summary:    A media thumbnail util library in Tizen Native API
-Version: 0.1.19
+Version: 0.1.20
 Release:    1
 Group:      Multimedia/API
 License:    Apache-2.0
index aff647746fccfcbc14e5324ae65d27f138cb0105..88e42925eaee206e7d866d2cd354de53397662b6 100644 (file)
@@ -52,33 +52,23 @@ int __thumbnail_util_replace_path(const char *path, char *replace_path)
        return THUMBNAIL_UTIL_ERROR_NONE;
 }
 
-int __thumbnail_util_error_capi(int content_error)
+int __thumbnail_util_error_capi(int internal_error)
 {
-       /*Error None*/
-       if (content_error == MS_MEDIA_ERR_NONE)
+       switch (internal_error) {
+       case MS_MEDIA_ERR_NONE:
                return THUMBNAIL_UTIL_ERROR_NONE;
-
-       /* Internal operation error*/
-       else if (content_error == MS_MEDIA_ERR_INVALID_PARAMETER)
+       case MS_MEDIA_ERR_INVALID_PARAMETER:
                return THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
-
-       else if (content_error == MS_MEDIA_ERR_OUT_OF_MEMORY)
+       case MS_MEDIA_ERR_OUT_OF_MEMORY:
                return THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY;
-
-       /* IPC operation error*/
-       else if (content_error == MS_MEDIA_ERR_IPC)
-               return THUMBNAIL_UTIL_ERROR_INVALID_OPERATION;
-
-       /* MEDIA SERVER error*/
-       else if (content_error == MS_MEDIA_ERR_PERMISSION_DENIED)
+       case MS_MEDIA_ERR_PERMISSION_DENIED:
                return THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED;
-
-       /* Thumbnail error*/
-       else if ((content_error == MS_MEDIA_ERR_THUMB_TOO_BIG) || (content_error == MS_MEDIA_ERR_THUMB_UNSUPPORTED))
-                       return THUMBNAIL_UTIL_ERROR_UNSUPPORTED_CONTENT;
-
-       /*ETC*/
-       return THUMBNAIL_UTIL_ERROR_INVALID_OPERATION;
+       case MS_MEDIA_ERR_THUMB_TOO_BIG:
+       case MS_MEDIA_ERR_THUMB_UNSUPPORTED:
+               return THUMBNAIL_UTIL_ERROR_UNSUPPORTED_CONTENT;
+       default:
+               return THUMBNAIL_UTIL_ERROR_INVALID_OPERATION;
+       }
 }
 
 void __thumbnail_util_convert_itoa(int request_id, char **req_str)
@@ -97,7 +87,7 @@ void __thumbnail_util_extract_completed_cb(int error, int request_id, const char
                __thumbnail_util_convert_itoa(request_id, &request_id_str);
                if (_thumb_cb->thumb_extract_cb)
                        _thumb_cb->thumb_extract_cb(__thumbnail_util_error_capi(error), request_id_str, thumb_width, thumb_height, thumb_data, thumb_size, _thumb_cb->user_data);
-
+               SAFE_FREE(request_id_str);
        }
        SAFE_FREE(_thumb_cb);
 }
index dd86720c10f94786e8d35115e5d71a6ee300c20e..e94c6ad42068130b71569c538871c9d7c75cdb9c 100644 (file)
@@ -118,6 +118,10 @@ gboolean cancel_all(gpointer data)
                        thumbnail_util_debug("thumbnail_util_cancel[%d] is success", i);
                else
                        thumbnail_util_error("thumbnail_util_cancel[%d] is failed", i);
+               if (req_str) {
+                       free(req_str);
+                       req_str = NULL;
+               }
        }
        thumbnail_util_destroy(_media_thumb);