# HG changeset patch
# User bae
# Date 1364497268 -14400
# Node ID a485d5bf84e653d1a89d609941275ac44c13c2f9
# Parent  ba8eb4f3c7b5b0301b55fa2950dd228d6d83ae39
8007925: Improve cmsStageAllocLabV2ToV4curves
8007926: Improve cmsPipelineDup
Reviewed-by: bae, prr
Contributed-by: jia-hong.chen@oracle.com

diff --git a/src/share/native/sun/java2d/cmm/lcms/cmslut.c b/src/share/native/sun/java2d/cmm/lcms/cmslut.c
--- openjdk/jdk/src/share/native/sun/java2d/cmm/lcms/cmslut.c
+++ openjdk/jdk/src/share/native/sun/java2d/cmm/lcms/cmslut.c
@@ -1021,6 +1021,7 @@
     mpe = cmsStageAllocToneCurves(ContextID, 3, LabTable);
     cmsFreeToneCurveTriple(LabTable);
 
+    if (mpe == NULL) return mpe;
     mpe ->Implements = cmsSigLabV2toV4;
     return mpe;
 }
@@ -1424,6 +1425,8 @@
     if (lut == NULL) return NULL;
 
     NewLUT = cmsPipelineAlloc(lut ->ContextID, lut ->InputChannels, lut ->OutputChannels);
+    if (NewLUT == NULL) return NULL;
+
     for (mpe = lut ->Elements;
          mpe != NULL;
          mpe = mpe ->Next) {
