mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
Added detection for broken WAD files
Do not try to allocate nonsensical amount of memory and bail out when broken WAD is detected See http://forum.drdteam.org/viewtopic.php?t=6844
This commit is contained in:
parent
93323b64f8
commit
9b23b41021
1 changed files with 7 additions and 0 deletions
|
@ -39,6 +39,7 @@
|
|||
#include "v_text.h"
|
||||
#include "w_wad.h"
|
||||
#include "gi.h"
|
||||
#include "i_system.h"
|
||||
|
||||
// Console Doom LZSS wrapper.
|
||||
class FileReaderLZSS : public FileReaderBase
|
||||
|
@ -343,6 +344,12 @@ bool FWadFile::Open(bool quiet)
|
|||
NumLumps = BigLong(header.NumLumps);
|
||||
InfoTableOfs = BigLong(header.InfoTableOfs);
|
||||
isBigEndian = true;
|
||||
|
||||
// Check again to detect broken wads
|
||||
if (InfoTableOfs + NumLumps*sizeof(wadlump_t) > (unsigned)wadSize)
|
||||
{
|
||||
I_Error("Cannot load broken WAD file %s\n", Filename);
|
||||
}
|
||||
}
|
||||
|
||||
wadlump_t *fileinfo = new wadlump_t[NumLumps];
|
||||
|
|
Loading…
Reference in a new issue