6829549: JVM crash on certain images
authorbae
Mon, 15 Jun 2009 14:49:22 +0400
changeset 3013 d661931d1ca0
parent 3012 1420628f14e4
child 3014 85cbc1221cc0
6829549: JVM crash on certain images Reviewed-by: igor, prr
jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
--- 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);
+            }
         }
     }