8007929: Improve CurvesAlloc
authorjgodinez
Wed, 20 Mar 2013 10:12:37 -0700
changeset 18200 7b3ae6f27043
parent 18199 bfd86c4f4249
child 18201 f0c28a4c1ab2
8007929: Improve CurvesAlloc Reviewed-by: bae, mschoene, prr Contributed-by: jia-hong.chen@oracle.com
jdk/src/share/native/sun/java2d/cmm/lcms/cmsopt.c
--- a/jdk/src/share/native/sun/java2d/cmm/lcms/cmsopt.c	Tue Mar 19 14:59:33 2013 -0700
+++ b/jdk/src/share/native/sun/java2d/cmm/lcms/cmsopt.c	Wed Mar 20 10:12:37 2013 -0700
@@ -1201,6 +1201,15 @@
     for (i=0; i < nCurves; i++) {
 
         c16->Curves[i] = _cmsCalloc(ContextID, nElements, sizeof(cmsUInt16Number));
+        if (c16->Curves[i] == NULL) {
+            for (j=0; j < i; j++) {
+                _cmsFree(ContextID, c16->Curves[j]);
+            }
+            _cmsFree(ContextID, c16->Curves);
+            _cmsFree(ContextID, c16);
+
+            return NULL;
+        }
 
         if (nElements == 256) {