From a28e7a71bd90685767bda943b808d61febd8af05 Mon Sep 17 00:00:00 2001 From: Jiyong Date: Wed, 22 Jan 2025 14:58:49 +0900 Subject: [PATCH] Bug fix. Modify the error checking for jpeg_read_scanlines() function - In normal cases, the msg_code is not 0 for logging. So we change the error checking to check return value. Change-Id: I5c1a2d4f77bd72f663b913a2533b8d6a0c90b22d --- jpeg/mm_util_jpeg.c | 11 +++++------ packaging/libmm-utility.spec | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/jpeg/mm_util_jpeg.c b/jpeg/mm_util_jpeg.c index a963f97..614ed22 100644 --- a/jpeg/mm_util_jpeg.c +++ b/jpeg/mm_util_jpeg.c @@ -30,6 +30,7 @@ /* maximum width of encoding */ #define ENC_MAX_LEN 8192 +#define NUM_OF_SCANLINES 1 typedef enum { MM_UTIL_JPEG_FILE, @@ -447,9 +448,8 @@ static int __mm_util_jpeg_decode(mm_util_jpeg_ctrl_format_e control_format, FILE int i = 0; int y = 0; while (dinfo.output_scanline < dinfo.output_height) { - jpeg_read_scanlines(&dinfo, buffer, 1); - if (dinfo.err->msg_code != 0) { - mm_util_error("jpeg_read_scanlines failed"); + if (jpeg_read_scanlines(&dinfo, buffer, NUM_OF_SCANLINES) != NUM_OF_SCANLINES) { + mm_util_error("jpeg_read_scanlines failed (msg_code: %d)", dinfo.err->msg_code); ret = MM_UTIL_ERROR_INVALID_OPERATION; goto END; } @@ -471,9 +471,8 @@ static int __mm_util_jpeg_decode(mm_util_jpeg_ctrl_format_e control_format, FILE int state = 0; while (dinfo.output_scanline < dinfo.output_height) { /* jpeg_read_scanlines expects an array of pointers to scanlines. Here the array is only one element long, but you could ask formore than one scanline at a time if that's more convenient. */ - jpeg_read_scanlines(&dinfo, buffer, 1); - if (dinfo.err->msg_code != 0) { - mm_util_error("jpeg_read_scanlines failed"); + if (jpeg_read_scanlines(&dinfo, buffer, NUM_OF_SCANLINES) != NUM_OF_SCANLINES) { + mm_util_error("jpeg_read_scanlines failed (msg_code: %d)", dinfo.err->msg_code); ret = MM_UTIL_ERROR_INVALID_OPERATION; goto END; } diff --git a/packaging/libmm-utility.spec b/packaging/libmm-utility.spec index 14aa885..cafd02b 100644 --- a/packaging/libmm-utility.spec +++ b/packaging/libmm-utility.spec @@ -1,6 +1,6 @@ Name: libmm-utility Summary: Multimedia Framework Utility Library -Version: 0.4.26 +Version: 0.4.27 Release: 0 Group: System/Libraries License: Apache-2.0 -- 2.34.1