- fixed crash on bad PNGs.

The cast to a signed long could create negative numbers which failed the sanity check and caused a stack corruption.
This commit is contained in:
Christoph Oelckers 2017-04-11 10:28:21 +02:00
parent f049e6145b
commit 1febf277af

View file

@ -576,7 +576,7 @@ bool M_ReadIDAT (FileReader *file, uint8_t *buffer, int width, int height, int p
if (stream.avail_in == 0 && chunklen > 0) if (stream.avail_in == 0 && chunklen > 0)
{ {
stream.next_in = chunkbuffer; stream.next_in = chunkbuffer;
stream.avail_in = (uInt)file->Read (chunkbuffer, MIN<long>(chunklen,sizeof(chunkbuffer))); stream.avail_in = (uInt)file->Read (chunkbuffer, MIN<uint32_t>(chunklen,sizeof(chunkbuffer)));
chunklen -= stream.avail_in; chunklen -= stream.avail_in;
} }