6829549: JVM crash on certain images

Reviewed-by: igor, prr
This commit is contained in:
Andrew Brygin 2009-06-15 14:49:22 +04:00
parent d78db1b0c7
commit 5ecb6c24be

View File

@ -41,6 +41,7 @@ import java.awt.Rectangle;
import java.awt.color.ColorSpace;
import java.awt.color.ICC_Profile;
import java.awt.color.ICC_ColorSpace;
import java.awt.color.CMMException;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
@ -629,6 +630,17 @@ public class JPEGImageReader extends ImageReader {
!java.util.Arrays.equals(oldData, newData))
{
iccCS = new ICC_ColorSpace(newProfile);
// verify new color space
try {
float[] colors = iccCS.fromRGB(new float[] {1f, 0f, 0f});
} catch (CMMException e) {
/*
* Embedded profile seems to be corrupted.
* Ignore this profile.
*/
iccCS = null;
warningOccurred(WARNING_IGNORE_INVALID_ICC);
}
}
}