Skip to content

Commit

Permalink
Fixes from JDK9
Browse files Browse the repository at this point in the history
Fixes contributed by Java JDK folks. Thank you!
  • Loading branch information
Marti committed Oct 19, 2016
1 parent 892b758 commit c0a98d8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cmsintrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void LinLerp1D(register const cmsUInt16Number Value[],
// To prevent out of bounds indexing
cmsINLINE cmsFloat32Number fclamp(cmsFloat32Number v)
{
return v < 0.0f ? 0.0f : (v > 1.0f ? 1.0f : v);
return ((v < 0.0f) || isnan(v)) ? 0.0f : (v > 1.0f ? 1.0f : v);
}

// Floating-point version of 1D interpolation
Expand Down
11 changes: 11 additions & 0 deletions src/cmsio0.c
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,17 @@ void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig)
// If the element is already in memory, return the pointer
if (Icc -> TagPtrs[n]) {

if (Icc->TagTypeHandlers[n] == NULL) goto Error;

// Sanity check
BaseType = Icc->TagTypeHandlers[n]->Signature;
if (BaseType == 0) goto Error;

TagDescriptor = _cmsGetTagDescriptor(Icc->ContextID, sig);
if (TagDescriptor == NULL) goto Error;

if (!IsTypeSupported(TagDescriptor, BaseType)) goto Error;

if (Icc ->TagSaveAsRaw[n]) goto Error; // We don't support read raw tags as cooked

_cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
Expand Down
6 changes: 5 additions & 1 deletion src/cmstypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4287,8 +4287,12 @@ void *Type_MPEclut_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,

// Copy MAX_INPUT_DIMENSIONS at most. Expand to cmsUInt32Number
nMaxGrids = InputChans > MAX_INPUT_DIMENSIONS ? MAX_INPUT_DIMENSIONS : InputChans;
for (i=0; i < nMaxGrids; i++) GridPoints[i] = (cmsUInt32Number) Dimensions8[i];

for (i = 0; i < nMaxGrids; i++) {
if (Dimensions8[i] == 1) goto Error; // Impossible value, 0 for no CLUT and then 2 at least
GridPoints[i] = (cmsUInt32Number)Dimensions8[i];
}

// Allocate the true CLUT
mpe = cmsStageAllocCLutFloatGranular(self ->ContextID, GridPoints, InputChans, OutputChans, NULL);
if (mpe == NULL) goto Error;
Expand Down

0 comments on commit c0a98d8

Please sign in to comment.