Skip to content

Commit

Permalink
Fix a possible leak when dealing with corrupted profiles in postscrip…
Browse files Browse the repository at this point in the history
…t generation

Only possible on corrupted profiles
  • Loading branch information
mm2 committed May 2, 2024
1 parent 75ac9fa commit d909bb6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/cmsps2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ void EmitXYZ2Lab(cmsIOHANDLER* m)
// 8 bits.

static
int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags)
cmsBool WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent, cmsUInt32Number dwFlags)
{
cmsHPROFILE hLab;
cmsHTRANSFORM xform;
Expand All @@ -1281,7 +1281,7 @@ int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent
cmsStage* first;

hLab = cmsCreateLab4ProfileTHR(m ->ContextID, NULL);
if (hLab == NULL) return 0;
if (hLab == NULL) return FALSE;

OutputFormat = cmsFormatterForColorspaceOfProfile(hProfile, 2, FALSE);
nChannels = T_CHANNELS(OutputFormat);
Expand All @@ -1306,7 +1306,7 @@ int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent

if (xform == NULL) {
cmsSignalError(m ->ContextID, cmsERROR_COLORSPACE_CHECK, "Cannot create transform Lab -> Profile in CRD creation");
return 0;
return FALSE;
}

// Get a copy of the internal devicelink
Expand All @@ -1315,21 +1315,21 @@ int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent
if (DeviceLink == NULL) {
cmsDeleteTransform(xform);
cmsSignalError(m->ContextID, cmsERROR_CORRUPTION_DETECTED, "Cannot access link for CRD");
return 0;
return FALSE;
}

// We need a CLUT
dwFlags |= cmsFLAGS_FORCE_CLUT;
if (!_cmsOptimizePipeline(m->ContextID, &DeviceLink, RelativeEncodingIntent, &InFrm, &OutputFormat, &dwFlags)) {
cmsPipelineFree(DeviceLink);
cmsDeleteTransform(xform);
cmsSignalError(m->ContextID, cmsERROR_CORRUPTION_DETECTED, "Cannot create CLUT table for CRD");
return 0;
return FALSE;
}

_cmsIOPrintf(m, "<<\n");
_cmsIOPrintf(m, "/ColorRenderingType 1\n");


cmsDetectBlackPoint(&BlackPointAdaptedToD50, hProfile, Intent, 0);

// Emit headers, etc.
Expand Down Expand Up @@ -1373,7 +1373,7 @@ int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent
cmsPipelineFree(DeviceLink);
cmsDeleteTransform(xform);

return 1;
return TRUE;
}


Expand Down

0 comments on commit d909bb6

Please sign in to comment.