From 3451eeb8f10aadb6aec2fa6981f7a9f2e1fd9e81 Mon Sep 17 00:00:00 2001 From: hj kim Date: Mon, 16 Sep 2019 15:17:31 +0900 Subject: Fix Coverity issue Change-Id: Ia4cd11b915f333a18b31e90d29710d6b1bf32dca --- src/include/media-thumb-internal.h | 2 +- src/media-thumb-internal.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/include/media-thumb-internal.h b/src/include/media-thumb-internal.h index b0f84fe..2b9b271 100755 --- a/src/include/media-thumb-internal.h +++ b/src/include/media-thumb-internal.h @@ -47,7 +47,7 @@ typedef struct { void *user_data; } thumbRawUserData; -int _media_thumb_image(const char *origin_path, char *thumb_path, int thumb_width, int thumb_height, media_thumb_info *thumb_info); +int _media_thumb_image(const char *origin_path, char *thumb_path, unsigned int thumb_width, unsigned int thumb_height, media_thumb_info *thumb_info); int _media_thumb_video(const char *origin_path, const char *thumb_path, int thumb_width, int thumb_height, media_thumb_info *thumb_info); int _media_thumb_get_hash_name(const char *file_full_path, char *thumb_hash_path, size_t max_thumb_path, uid_t uid); diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c index 9899783..3b3016e 100755 --- a/src/media-thumb-internal.c +++ b/src/media-thumb-internal.c @@ -32,10 +32,15 @@ #include #include -static void __media_thumb_get_proper_thumb_size(int origin_width, int origin_height, int *thumb_width, int *thumb_height) +static void __media_thumb_get_proper_thumb_size(unsigned int origin_width, unsigned int origin_height, unsigned int *thumb_width, unsigned int *thumb_height) { bool portrait = false; - double ratio; + double ratio = 0.0; + + thumb_retm_if(origin_width == 0, "Invalid origin_width"); + thumb_retm_if(origin_height == 0, "Invalid origin_height"); + thumb_retm_if(!thumb_width, "Invalid thumb_width"); + thumb_retm_if(!thumb_height, "Invalid thumb_height"); if (origin_width < origin_height) portrait = true; @@ -88,7 +93,7 @@ int _media_thumb_general(const char *origin_path, const char *thumb_path, int th return err; } -int _media_thumb_image(const char *origin_path, char *thumb_path, int thumb_width, int thumb_height, media_thumb_info *thumb_info) +int _media_thumb_image(const char *origin_path, char *thumb_path, unsigned int thumb_width, unsigned int thumb_height, media_thumb_info *thumb_info) { int err = MS_MEDIA_ERR_NONE; mm_util_img_codec_type image_type = 0; @@ -257,7 +262,7 @@ static int __get_video_info(int cdis_value, const char *origin_path, int *video_ return MS_MEDIA_ERR_NONE; } -static int __get_video_thumb(int width, int height, void *frame, size_t size, mm_util_magick_rotate_type rot_type, const char *thumb_path, int thumb_width, int thumb_height, mm_util_image_h *dst_img) +static int __get_video_thumb(int width, int height, void *frame, size_t size, mm_util_magick_rotate_type rot_type, const char *thumb_path, unsigned int thumb_width, unsigned int thumb_height, mm_util_image_h *dst_img) { int err = MS_MEDIA_ERR_NONE; mm_util_image_h img = NULL; -- cgit v1.2.3