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
14 changes: 13 additions & 1 deletion Tools/CmdLine/IccApplyProfiles/TiffImg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,17 @@ bool CTiffImg::Open(const char *szFname)
TIFFGetField(m_hTif, TIFFTAG_XRESOLUTION, &m_fXRes);
TIFFGetField(m_hTif, TIFFTAG_YRESOLUTION, &m_fYRes);
TIFFGetField(m_hTif, TIFFTAG_COMPRESSION, &m_nCompress);

if (m_nRowsPerStrip == 0 || m_nSamples == 0 || m_nBitsPerSample == 0) {
// Corrupt parameters - can't read the file
// If the file is uncompressed, we might guess some of the values,
// but it would take a bit of testing to get right. Probably not worth it.
Close();
return false;
}

if (m_nRowsPerStrip > m_nHeight)
m_nRowsPerStrip = m_nHeight; // best guess, to limit memory allocated

//Validate what we expect to work with
if ((m_nBitsPerSample==32 && nSampleFormat!=SAMPLEFORMAT_IEEEFP) ||
Expand All @@ -273,6 +284,7 @@ bool CTiffImg::Open(const char *szFname)
Close();
return false;
}

m_nCurStrip=(unsigned int)-1;
m_nCurLine = 0;

Expand Down Expand Up @@ -313,7 +325,7 @@ bool CTiffImg::Open(const char *szFname)

bool CTiffImg::ReadLine(unsigned char *pBuf)
{
if (!m_bRead)
if (!m_bRead || m_nRowsPerStrip == 0)
return false;

unsigned int nStrip = m_nCurLine / m_nRowsPerStrip;
Expand Down
Loading