view patches/openjdk/8005194-scale_memory_leak.patch @ 2929:222321136c48

Backport a number of JPEG fixes from 7u. S4893408: JPEGReader throws IllegalArgException when setting the destination to BYTE_GRAY S6631559: Registration of ImageIO plugins should not cause loading of jpeg.dlli and cmm.dll S6791502: IIOException "Invalid icc profile" on jpeg after update from JDK5 to JDK6 S6793818: JpegImageReader is too greedy creating color profiles S6888215: memory leak in jpeg plugin S6989760: cmm native compiler warnings S6989774: imageio compiler warnings in native code S7013519: [parfait] Integer overflows in 2D code S7018912: [parfait] potential buffer overruns in imageio jpeg S8005194: [parfait] #353 sun/awt/image/jpeg/imageioJPEG.c Memory leak of pointer 'scale' allocated with calloc() S8020983, RH976897: OutOfMemoryError caused by non garbage collected JPEGImageWriter Instances 2013-08-30 Andrew John Hughes <gnu.andrew@redhat.com> * Makefile.am: (ICEDTEA_PATCHES): Add new patches. * NEWS: Updated with new patches. * patches/imageiojpeg_sync.patch: Bring in changes to imageioJPEG.c made between the start of OpenJDK 6 and the start of OpenJDK 7's hg repositories. * patches/libraries.patch: Updated against patches below. * patches/openjdk/4893408-jpegreader_byte_gray.patch, * patches/openjdk/6631559-dont_load_libjpeg_to_register_imageio_plugins.patch, * patches/openjdk/6791502-invalid_icc_profile.patch, * patches/openjdk/6793818-jpegimagereader_too_greedy.patch, * patches/openjdk/6888215-jpeg_memory_leak.patch, * patches/openjdk/6989760-native_warnings.patch, * patches/openjdk/6989774-imageio_compiler_warnings.patch, * patches/openjdk/7013519-integer_overflows.patch, * patches/openjdk/7018912-potential_buffer_overruns_in_jpeg.patch, * patches/openjdk/8005194-scale_memory_leak.patch, * patches/openjdk/8020983-outofmemoryerror_jpegimagewriter.patch: New backports from OpenJDK 7u.
author Andrew John Hughes <gnu.andrew@redhat.com>
date Tue, 03 Sep 2013 20:08:26 +0100
parents
children
line wrap: on
line source

# HG changeset patch
# User jgodinez
# Date 1360190702 28800
#      Wed Feb 06 14:45:02 2013 -0800
# Node ID 37719b174e8705b5b7f01d55bceaeb1213805032
# Parent  8fc3e4015b090ebe974a842cf7f065e5af7429aa
8005194: [parfait] #353 sun/awt/image/jpeg/imageioJPEG.c Memory leak of pointer 'scale' allocated with calloc()
Reviewed-by: prr, vadim
Contributed-by: jia-hong.chen@oracle.com

diff --git a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
--- openjdk/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
+++ openjdk/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
@@ -2694,6 +2694,11 @@
             scale[i] = (UINT8*) malloc((maxBandValue + 1) * sizeof(UINT8));
 
             if (scale[i] == NULL) {
+                // Cleanup before throwing an out of memory exception
+                for (j = 0; j < i; j++) {
+                    free(scale[j]);
+                }
+                free(scale);
                 JNU_ThrowByName( env, "java/lang/OutOfMemoryError",
                                  "Writing JPEG Stream");
                 return JNI_FALSE;