Don't read DDS header twice, reallow triggering eof()

pull/1175/head
Andrew Tribick 2021-11-17 00:21:46 +01:00 committed by ajtribick
parent 6e7787faf3
commit e686619f2e
1 changed files with 1 additions and 2 deletions

View File

@ -144,7 +144,6 @@ Image* LoadDDSImage(const fs::path& filename)
}
char header[4];
in.read(header, sizeof header);
if (!in.read(header, sizeof(header)).good()
|| header[0] != 'D' || header[1] != 'D'
|| header[2] != 'S' || header[3] != ' ')
@ -301,7 +300,7 @@ Image* LoadDDSImage(const fs::path& filename)
(int) ddsd.height,
max(ddsd.mipMapLevels, 1u));
in.read(reinterpret_cast<char*>(img->getPixels()), img->getSize());
if (!in.good())
if (!in.eof() && !in.good())
{
DPRINTF(LOG_LEVEL_ERROR, "Failed reading data from DDS texture file %s.\n", filename);
delete img;