changeset 1291:0ce29cbeb6a9

6829549: JVM crash on certain images Reviewed-by: igor, prr
author bae
date Mon, 15 Jun 2009 14:49:22 +0400
parents e138ae33b128
children 5896dcd01fe3
files src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java	Thu Jun 11 14:22:33 2009 +0400
+++ b/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);
+            }
         }
     }