7051394: NullPointerException when running regression tests LoadProfileTest by using openjdk-7-b144
authorbae
Tue, 23 Oct 2012 13:10:52 +0400
changeset 14154 9acc7f86a458
parent 14066 cdaa6122185f
child 14155 0f28da8d3c45
child 14300 117dc9b98a7b
7051394: NullPointerException when running regression tests LoadProfileTest by using openjdk-7-b144 Reviewed-by: jgodinez, prr
jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c
--- a/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c	Wed Jul 05 18:26:11 2017 +0200
+++ b/jdk/src/share/native/sun/java2d/cmm/lcms/LCMS.c	Tue Oct 23 13:10:52 2012 +0400
@@ -253,6 +253,16 @@
 
     if (sProf.pf == NULL) {
         JNU_ThrowIllegalArgumentException(env, "Invalid profile data");
+    } else {
+        /* Sanity check: try to save the profile in order
+         * to force basic validation.
+         */
+        cmsUInt32Number pfSize = 0;
+        if (!cmsSaveProfileToMem(sProf.pf, NULL, &pfSize) ||
+            pfSize < sizeof(cmsICCHeader))
+        {
+            JNU_ThrowIllegalArgumentException(env, "Invalid profile data");
+        }
     }
 
     return sProf.j;