Skip to content

Commit ed4dcc2

Browse files
committed
Fix CImageLoaderJPG::isALoadableFileFormat according to upstream
1 parent 1b42688 commit ed4dcc2

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

lib/irrlicht/source/Irrlicht/CImageLoaderJPG.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,11 @@ bool CImageLoaderJPG::isALoadableFileFormat(io::IReadFile* file) const
120120
return false;
121121
#else
122122

123-
if (!file)
123+
if (!(file && file->seek(0)))
124124
return false;
125-
126-
s32 jfif = 0;
127-
file->seek(6);
128-
file->read(&jfif, sizeof(s32));
129-
return (jfif == 0x4a464946 || jfif == 0x4649464a);
130-
125+
unsigned char header[3];
126+
size_t headerLen = file->read(header, sizeof(header));
127+
return headerLen >= 3 && !memcmp(header, "\xFF\xD8\xFF", 3);
131128
#endif
132129
}
133130

0 commit comments

Comments
 (0)