From: minje.ahn Date: Thu, 22 Feb 2024 01:54:58 +0000 (+0900) Subject: Prevent unintentional progress X-Git-Tag: accepted/tizen/unified/20240226.134008~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=87b9a35f728a4d02bde0a125f6cf608adf1ec60e;p=platform%2Fcore%2Fmultimedia%2Flibmm-utility.git Prevent unintentional progress [issue] If 'option' is NULL, JPEG definition is added regardless of the file type. [fix] Add 'option' checker. Change-Id: Ib0d143a27e50d3a363fb4385c225fd280b69be6f Signed-off-by: minje.ahn --- diff --git a/magick/mm_util_magick.c b/magick/mm_util_magick.c index 4ae4167..63cd05a 100644 --- a/magick/mm_util_magick.c +++ b/magick/mm_util_magick.c @@ -346,7 +346,6 @@ static int __mm_util_write_image_to_file(Image *image, mm_util_enc_opt_t *option int ret = MM_UTIL_ERROR_NONE; ImageInfo *_image_info = NULL; ExceptionInfo exception; - mm_util_img_codec_type codec = IMG_CODEC_JPEG; mm_util_fenter(); @@ -369,38 +368,37 @@ static int __mm_util_write_image_to_file(Image *image, mm_util_enc_opt_t *option DeleteImageProfile(image, "IPTC"); DeleteImageProfile(image, "XMP"); - if (option) - codec = option->codec; - - switch (codec) { - case IMG_CODEC_JPEG: - AddDefinition(_image_info, "jpeg", "dct-method", "FASTEST", &exception); - AddDefinition(_image_info, "jpeg", "optimize-coding", "FALSE", &exception); - break; - - case IMG_CODEC_PNG: - mm_util_sec_debug("PNG compression: %d", option->compression); - _image_info->quality = option->compression * 10; - break; - - case IMG_CODEC_WEBP: - mm_util_sec_debug("WEBP lossless: %s", (option->lossless ? "TRUE" : "FALSE")); - AddDefinition(_image_info, "webp", "lossless", (option->lossless ? "TRUE" : "FALSE"), &exception); - break; - - case IMG_CODEC_GIF: - /* fall through */ - case IMG_CODEC_BMP: - /* fall through */ - case IMG_CODEC_WBMP: - break; - - default: - mm_util_error("invalid codec [%d]", codec); - break; + if (option) { + switch (option->codec) { + case IMG_CODEC_JPEG: + AddDefinition(_image_info, "jpeg", "dct-method", "FASTEST", &exception); + AddDefinition(_image_info, "jpeg", "optimize-coding", "FALSE", &exception); + break; + + case IMG_CODEC_PNG: + mm_util_sec_debug("PNG compression: %d", option->compression); + _image_info->quality = option->compression * 10; + break; + + case IMG_CODEC_WEBP: + mm_util_sec_debug("WEBP lossless: %s", (option->lossless ? "TRUE" : "FALSE")); + AddDefinition(_image_info, "webp", "lossless", (option->lossless ? "TRUE" : "FALSE"), &exception); + break; + + case IMG_CODEC_GIF: + /* fall through */ + case IMG_CODEC_BMP: + /* fall through */ + case IMG_CODEC_WBMP: + break; + + default: + mm_util_error("invalid codec [%d]", option->codec); + break; + } } - if (WriteImage (_image_info, image) == MagickFalse) { + if (WriteImage(_image_info, image) == MagickFalse) { mm_util_error("Error: Writing Image failed."); if (exception.severity != UndefinedException) CatchException(&exception);