8005194: [parfait] #353 sun/awt/image/jpeg/imageioJPEG.c Memory leak of pointer 'scale' allocated with calloc()

Reviewed-by: prr, vadim
This commit is contained in:
Jia-Hong Chen 2013-02-06 14:45:02 -08:00 committed by Jennifer Godinez
parent 78b547afa7
commit fb6927c36c

View File

@ -2694,6 +2694,11 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage
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;