Fix memory leak issue after png image is decoded 93/73393/1 accepted/tizen/common/20160609.145216 accepted/tizen/ivi/20160609.091737 accepted/tizen/mobile/20160609.091956 accepted/tizen/tv/20160609.091607 accepted/tizen/wearable/20160609.091711 submit/tizen/20160609.040222
authorJiyong Min <jiyong.min@samsung.com>
Wed, 8 Jun 2016 04:26:09 +0000 (13:26 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Wed, 8 Jun 2016 04:27:50 +0000 (13:27 +0900)
Change-Id: Idf1d376c7639d5b167690524d4a81e50a96ce4e9
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
png/mm_util_png.c

index 7d9987f..89cac72 100755 (executable)
@@ -471,13 +471,9 @@ int write_png(void **data, mm_util_png_data *encoded, FILE *fp)
        row_pointers = png_malloc(png_ptr, sizeof(png_bytep) * encoded->height);
 
        for (row_index = 0; row_index < encoded->height; row_index++) {
-               row_pointers[row_index] = png_malloc(png_ptr, encoded->png.rowbytes);
-               memcpy(row_pointers[row_index], *data, encoded->png.rowbytes);
-               *data += encoded->png.rowbytes;
+               row_pointers[row_index] = (*data) + (row_index * encoded->png.rowbytes);
        }
 
-       *data -= encoded->png.rowbytes * encoded->height;
-
        png_write_info(png_ptr, info_ptr);
        png_write_image(png_ptr, row_pointers);
        png_write_end(png_ptr, NULL);