Skip to content

Commit

Permalink
psd: use byte counts for scan lines
Browse files Browse the repository at this point in the history
  • Loading branch information
qbnu committed Jun 12, 2024
1 parent 57ac9bc commit e8d98fd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/JPEGView/PSDWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ CJPEGImage* PsdReader::ReadImage(LPCTSTR strFileName, bool& bOutOfMemory)
if (nCompressionMethod == COMPRESSION_RLE) {
// Skip byte counts for scanlines
p += nHeight * nRealChannels * 2;
ThrowIf(p >= (unsigned char*)pBuffer + nImageDataSize);
unsigned char* pOffset = p;
for (unsigned channel = 0; channel < nChannels; channel++) {
unsigned rchannel;
if (nColorMode == MODE_Lab) {
Expand All @@ -308,9 +310,14 @@ CJPEGImage* PsdReader::ReadImage(LPCTSTR strFileName, bool& bOutOfMemory)
rchannel = (-channel - 2) % nChannels;
}
for (unsigned row = 0; row < nHeight; row++) {
pOffset += _byteswap_ushort(*(unsigned short *)(pBuffer + (channel * nHeight + row) * 2));
p = pOffset;

for (unsigned count = 0; count < nWidth; ) {
unsigned char c;
ThrowIf(p >= (unsigned char*)pBuffer + nImageDataSize);
if (p >= (unsigned char*)pBuffer + nImageDataSize) {
break;
};
c = *p;
p += 1;

Expand Down

0 comments on commit e8d98fd

Please sign in to comment.