Bug fix. Modify the error checking for jpeg_read_scanlines() function 82/318682/3 accepted/tizen_unified_x_asan accepted/tizen/unified/20250123.054008 accepted/tizen/unified/x/20250123.071355 accepted/tizen/unified/x/asan/20250211.003431
authorJiyong <jiyong.min@samsung.com>
Wed, 22 Jan 2025 05:58:49 +0000 (14:58 +0900)
committerJiyong <jiyong.min@samsung.com>
Wed, 22 Jan 2025 06:13:36 +0000 (15:13 +0900)
 - 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
packaging/libmm-utility.spec

index a963f970bce5f858dd055558ae4e722dfbecf29d..614ed226c543bef1f54438a2786e7f4a34bd9870 100644 (file)
@@ -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;
                        }
index 14aa8850c4297634529d04a8823b7271b0fabde7..cafd02b48feb466e335df099a8deb46472a34a0b 100644 (file)
@@ -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