Home | History | Annotate | Download | only in lcms
      1 diff --git a/third_party/lcms/src/cmsxform.c b/third_party/lcms/src/cmsxform.c
      2 index 9c20c49b0..b3802f0d5 100644
      3 --- a/third_party/lcms/src/cmsxform.c
      4 +++ b/third_party/lcms/src/cmsxform.c
      5 @@ -761,7 +761,10 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
      6  
      7         // Allocate needed memory
      8         _cmsTRANSFORM* p = (_cmsTRANSFORM*)_cmsMallocZero(ContextID, sizeof(_cmsTRANSFORM));
      9 -       if (!p) return NULL;
     10 +       if (!p) {
     11 +          cmsPipelineFree(lut);
     12 +          return NULL;
     13 +      }
     14  
     15         // Store the proposed pipeline
     16         p->Lut = lut;
     17 @@ -819,7 +822,7 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
     18          if (p ->FromInputFloat == NULL || p ->ToOutputFloat == NULL) {
     19  
     20              cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported raster format");
     21 -            _cmsFree(ContextID, p);
     22 +            cmsDeleteTransform(p);
     23              return NULL;
     24          }
     25  
     26 @@ -849,7 +852,7 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
     27              if (p ->FromInput == NULL || p ->ToOutput == NULL) {
     28  
     29                  cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported raster format");
     30 -                _cmsFree(ContextID, p);
     31 +                cmsDeleteTransform(p);
     32                  return NULL;
     33              }
     34  
     35