From e97bdfa854f1dc3b7d5d6bc04ab06f6ee7f39c7e Mon Sep 17 00:00:00 2001 From: Jia-Hong Chen Date: Wed, 20 Mar 2013 10:12:37 -0700 Subject: [PATCH] 8007929: Improve CurvesAlloc Reviewed-by: bae, mschoene, prr --- jdk/src/share/native/sun/java2d/cmm/lcms/cmsopt.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jdk/src/share/native/sun/java2d/cmm/lcms/cmsopt.c b/jdk/src/share/native/sun/java2d/cmm/lcms/cmsopt.c index 808e03c0c98..7086109cecb 100644 --- a/jdk/src/share/native/sun/java2d/cmm/lcms/cmsopt.c +++ b/jdk/src/share/native/sun/java2d/cmm/lcms/cmsopt.c @@ -1201,6 +1201,15 @@ Curves16Data* CurvesAlloc(cmsContext ContextID, int nCurves, int nElements, cmsT 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) {