Skip to content

Commit a189456

Browse files
committed
Bugfix: PSD: properly skip image resource names
Skip Pascal strings properly Merge PR #308 by https://github.com/qbnu
2 parents 93b6f3b + 662ac15 commit a189456

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/JPEGView/PSDWrapper.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static inline unsigned short ReadUShortFromFile(HANDLE file) {
7979
}
8080

8181
// Read and return an unsigned char from file
82-
static inline unsigned short ReadUCharFromFile(HANDLE file) {
82+
static inline unsigned char ReadUCharFromFile(HANDLE file) {
8383
unsigned char val;
8484
ReadFromFile(&val, file, 1);
8585
return val;
@@ -191,7 +191,8 @@ CJPEGImage* PsdReader::ReadImage(LPCTSTR strFileName, bool& bOutOfMemory)
191191
unsigned short nResourceID = ReadUShortFromFile(hFile);
192192

193193
// Skip Pascal string (padded to be even length)
194-
while (ReadUShortFromFile(hFile));
194+
unsigned char nStringSize = ReadUCharFromFile(hFile);
195+
SeekFile(hFile, nStringSize | 1);
195196

196197
// Resource size
197198
unsigned int nResourceSize = ReadUIntFromFile(hFile);
@@ -437,7 +438,8 @@ CJPEGImage* PsdReader::ReadThumb(LPCTSTR strFileName, bool& bOutOfMemory)
437438
unsigned short nResourceID = ReadUShortFromFile(hFile);
438439

439440
// Skip Pascal string (padded to be even length)
440-
while (ReadUShortFromFile(hFile));
441+
unsigned char nStringSize = ReadUCharFromFile(hFile);
442+
SeekFile(hFile, nStringSize | 1);
441443

442444
// Resource size
443445
unsigned int nResourceSize = ReadUIntFromFile(hFile);

0 commit comments

Comments
 (0)