Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions IccProfLib/IccTagLut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1951,11 +1951,20 @@ bool CIccCLUT::Init(const icUInt8Number *pGridPoints, icUInt32Number nMaxSize, i
m_DimSize[i] = m_nOutput;
nNumPoints = m_GridPoints[i];
for (i--; i>=0; i--) {
m_DimSize[i] = m_DimSize[i+1] * m_GridPoints[i+1];
size_t dim1 = m_DimSize[i+1];
size_t fullSize = dim1 * m_GridPoints[i+1];
if (fullSize > 0xFFFFFFFFu)
return false;
m_DimSize[i] = (icUInt32Number)fullSize;
nNumPoints *= m_GridPoints[i];
if (nMaxSize && nNumPoints * m_nOutput * nBytesPerPoint > nMaxSize)
// carefullly protect against 64 bit overflow
if (nMaxSize && (nNumPoints > nMaxSize || nNumPoints * m_nOutput > nMaxSize
|| nNumPoints * m_nOutput * nBytesPerPoint > nMaxSize) )
return false;
}

if (nNumPoints > 0xFFFFFFFFu)
return false;
m_nNumPoints = (icUInt32Number)nNumPoints;

// Use 64-bit math to catch overflows even when no nMaxSize was
Expand Down
Loading