--- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java Thu Jun 11 14:22:33 2009 +0400
+++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java Mon Jun 15 14:49:22 2009 +0400
@@ -41,6 +41,7 @@
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 @@
!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);
+ }
}
}