Skip to content

Commit

Permalink
Fix for some minor issues
Browse files Browse the repository at this point in the history
Thanks to Jerry x2018 for reporting those.
  • Loading branch information
mm2 committed Nov 6, 2023
1 parent 178d734 commit d2c7f43
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/cmslut.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,13 @@ cmsBool CMSEXPORT cmsStageSampleCLutFloat(cmsStage* mpe, cmsSAMPLERFLOAT Sampler
cmsUInt32Number nInputs, nOutputs;
cmsUInt32Number* nSamples;
cmsFloat32Number In[MAX_INPUT_DIMENSIONS+1], Out[MAX_STAGE_CHANNELS];
_cmsStageCLutData* clut = (_cmsStageCLutData*) mpe->Data;
_cmsStageCLutData* clut;

if (mpe == NULL) return FALSE;

clut = (_cmsStageCLutData*)mpe->Data;

if (clut == NULL) return FALSE;

nSamples = clut->Params ->nSamples;
nInputs = clut->Params ->nInputs;
Expand Down
2 changes: 2 additions & 0 deletions src/cmsopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1728,6 +1728,8 @@ cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3

_cmsStageMatrixData* Data = (_cmsStageMatrixData*)cmsStageData(Matrix1);

if (Matrix1->InputChannels != 3 || Matrix1->OutputChannels != 3) return FALSE;

// Copy the matrix to our result
memcpy(&res, Data->Double, sizeof(res));

Expand Down
8 changes: 7 additions & 1 deletion src/cmstypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1919,7 +1919,7 @@ void *Type_LUT8_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cms

// We only allow a specific MPE structure: Matrix plus prelin, plus clut, plus post-lin.
static
cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
cmsUInt32Number j, nTabSize, i;
cmsUInt8Number val;
Expand All @@ -1932,6 +1932,12 @@ cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,

// Disassemble the LUT into components.
mpe = NewLUT -> Elements;

if (mpe == NULL) { // Should never be empty. Corrupted?
cmsSignalError(self->ContextID, cmsERROR_UNKNOWN_EXTENSION, "empty LUT8 is not supported");
return FALSE;
}

if (mpe ->Type == cmsSigMatrixElemType) {

if (mpe->InputChannels != 3 || mpe->OutputChannels != 3) return FALSE;
Expand Down

0 comments on commit d2c7f43

Please sign in to comment.