Add finishing jpeg decompression due to memory leak 16/149316/4 accepted/tizen/unified/20170920.065524 submit/tizen/20170918.031342
authorJiyong Min <jiyong.min@samsung.com>
Tue, 12 Sep 2017 05:29:49 +0000 (14:29 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Tue, 12 Sep 2017 05:41:30 +0000 (14:41 +0900)
 - The libjpeg release memory without stdio manager during compression
   So we should finish decompression before release jpeg source.
   If release jpeg decompression without finishing, jpeg_destroy_decompress makes memory leak.

Change-Id: Ic19ea9935edc0c461c7dcfad7670cd551f0525cc
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
jpeg/mm_util_jpeg.c
packaging/libmm-utility.spec

index 8886a35..95fc080 100755 (executable)
@@ -997,6 +997,7 @@ static int __mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data *
        } else if (input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
                decoded_data->size = dinfo.output_height * dinfo.output_width;
        } else{
+               jpeg_finish_decompress(&dinfo);
                jpeg_destroy_decompress(&dinfo);
                mm_util_error("[%d] We can't decode the IMAGE format", input_fmt);
                fclose(infile);
@@ -1007,6 +1008,7 @@ static int __mm_image_decode_from_jpeg_file_with_libjpeg(mm_util_jpeg_yuv_data *
        decoded_data->format = input_fmt;
 
        if (decoded_data->data == NULL) {
+               jpeg_finish_decompress(&dinfo);
                jpeg_destroy_decompress(&dinfo);
                mm_util_error("decoded_data->data is NULL");
                fclose(infile);
@@ -1180,6 +1182,7 @@ static int __mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data
        } else if (input_fmt == MM_UTIL_JPEG_FMT_GraySacle) {
                decoded_data->size = dinfo.output_height * dinfo.output_width;
        } else{
+               jpeg_finish_decompress(&dinfo);
                jpeg_destroy_decompress(&dinfo);
                mm_util_error("[%d] We can't decode the IMAGE format", input_fmt);
                return MM_UTIL_ERROR_NOT_SUPPORTED_FORMAT;
@@ -1189,6 +1192,7 @@ static int __mm_image_decode_from_jpeg_memory_with_libjpeg(mm_util_jpeg_yuv_data
        decoded_data->format = input_fmt;
 
        if (decoded_data->data == NULL) {
+               jpeg_finish_decompress(&dinfo);
                jpeg_destroy_decompress(&dinfo);
                mm_util_error("decoded_data->data is NULL");
                return MM_UTIL_ERROR_OUT_OF_MEMORY;
index 65cb041..ef92872 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-utility
 Summary:    Multimedia Framework Utility Library
-Version:    0.40
+Version:    0.41
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0