Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 13 additions & 7 deletions IccProfLib/IccTagBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2348,12 +2348,13 @@ void CIccTagTextDescription::Release()
*/
icUInt16Number *CIccTagTextDescription::GetUnicodeBuffer(icUInt32Number nSize)
{
if (m_nUnicodeSize < nSize) {
m_uzUnicodeText = (icUInt16Number*)icRealloc(m_uzUnicodeText, (nSize+1)*sizeof(icUInt16Number));
if (m_nUnicodeSize < (nSize+2)) { // test for existing size must include the NULL termination!
m_uzUnicodeText = (icUInt16Number*)icRealloc(m_uzUnicodeText, (nSize+2)*sizeof(icUInt16Number));

m_uzUnicodeText[nSize] = 0;
m_uzUnicodeText[nSize+1] = 0;

m_nUnicodeSize = nSize;
m_nUnicodeSize = nSize+2;
}

return m_uzUnicodeText;
Expand All @@ -2370,13 +2371,18 @@ icUInt16Number *CIccTagTextDescription::GetUnicodeBuffer(icUInt32Number nSize)
void CIccTagTextDescription::ReleaseUnicode()
{
int i;
for (i=0; m_uzUnicodeText[i]; i++);
// even if the string is not NULL terminated, don't read over the end!
for (i=0; i < (int)m_nUnicodeSize && m_uzUnicodeText[i]; i++);

icUInt32Number nSize = i+1;

if (nSize < m_nUnicodeSize-1) {
m_uzUnicodeText=(icUInt16Number*)icRealloc(m_uzUnicodeText, (nSize+1)*sizeof(icUInt16Number));
m_nUnicodeSize = nSize+1;
// try to keep 2 NULLs at the end, to deal with malformed unicode
// but don't reallocate because of the NULLs
if (nSize < (m_nUnicodeSize-2)) {
m_uzUnicodeText=(icUInt16Number*)icRealloc(m_uzUnicodeText, (nSize+2)*sizeof(icUInt16Number));
m_uzUnicodeText[nSize] = 0;
m_uzUnicodeText[nSize+1] = 0;
m_nUnicodeSize = nSize+2;
}
}

Expand Down
50 changes: 24 additions & 26 deletions IccProfLib/IccTagLut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4422,22 +4422,18 @@ icValidateStatus CIccTagLutBtoA::Validate(std::string sigPath, std::string &sRep
case icSigBToA2Tag:
case icSigGamutTag:
{
icUInt32Number nInput = icGetSpaceSamples(pProfile->m_Header.pcs);
// icUInt32Number nInput = icGetSpaceSamples(pProfile->m_Header.colorSpace);
// icUInt32Number nOutput = icGetSpaceSamples(pProfile->m_Header.pcs);
// m_nInput should match nInput, and m_nOutput should match nOutput
// That is validated in CIccMBB::Validate
// Here we don't want to crash while validating the curves, even if the count of them is incorrect, so we use the same counts obtained from reading the LUT.

icUInt32Number nInput = m_nInput;
icUInt32Number nOutput = m_nOutput;

icUInt32Number nOutput;
if (sig==icSigGamutTag) {
nOutput = 1;
}
else {
nOutput = icGetSpaceSamples(pProfile->m_Header.colorSpace);
}

if (m_nOutput!=nOutput) {
sReport += icMsgValidateCriticalError;
sReport += sSigPathName;
sReport += " - Incorrect number of output channels.\n";
rv = icMaxStatus(rv, icValidateCriticalError);
}

icUInt8Number i;
if (m_CurvesB) {
Expand Down Expand Up @@ -4863,13 +4859,14 @@ icValidateStatus CIccTagLut8::Validate(std::string sigPath, std::string &sReport
case icSigBToA2Tag:
case icSigGamutTag:
{
icUInt32Number nInput, nOutput;

nInput = icGetSpaceSamples(pProfile->m_Header.pcs);
nOutput = icGetSpaceSamples(pProfile->m_Header.colorSpace);

if (sig==icSigAToB0Tag || sig==icSigAToB1Tag || sig==icSigAToB2Tag)
std::swap(nInput,nOutput);
// icUInt32Number nInput = icGetSpaceSamples(pProfile->m_Header.colorSpace);
// icUInt32Number nOutput = icGetSpaceSamples(pProfile->m_Header.pcs);
// m_nInput should match nInput, and m_nOutput should match nOutput
// That is validated in CIccMBB::Validate
// Here we don't want to crash while validating the curves, even if the count of them is incorrect, so we use the same counts obtained from reading the LUT.

icUInt32Number nInput = m_nInput;
icUInt32Number nOutput = m_nOutput;

if (sig==icSigGamutTag) {
nOutput = 1;
Expand Down Expand Up @@ -5288,13 +5285,14 @@ icValidateStatus CIccTagLut16::Validate(std::string sigPath, std::string &sRepor
case icSigBToA2Tag:
case icSigGamutTag:
{
icUInt32Number nInput, nOutput;

nInput = icGetSpaceSamples(pProfile->m_Header.pcs);
nOutput = icGetSpaceSamples(pProfile->m_Header.colorSpace);

if (sig==icSigAToB0Tag || sig==icSigAToB1Tag || sig==icSigAToB2Tag)
std::swap(nInput,nOutput);
// icUInt32Number nInput = icGetSpaceSamples(pProfile->m_Header.colorSpace);
// icUInt32Number nOutput = icGetSpaceSamples(pProfile->m_Header.pcs);
// m_nInput should match nInput, and m_nOutput should match nOutput
// That is validated in CIccMBB::Validate
// Here we don't want to crash while validating the curves, even if the count of them is incorrect, so we use the same counts obtained from reading the LUT.

icUInt32Number nInput = m_nInput;
icUInt32Number nOutput = m_nOutput;

if (sig==icSigGamutTag) {
nOutput = 1;
Expand Down
Loading