diff --git a/src/resourcefiles/file_wad.cpp b/src/resourcefiles/file_wad.cpp index c7a3a262f..a0ae033db 100644 --- a/src/resourcefiles/file_wad.cpp +++ b/src/resourcefiles/file_wad.cpp @@ -188,6 +188,17 @@ bool FWadFile::Open(bool quiet) Lumps[i].Namespace = ns_global; Lumps[i].Flags = Lumps[i].Compressed? LUMPF_COMPRESSED : 0; Lumps[i].FullName = NULL; + + // Check if the lump is within the WAD file and print a warning if not. + if (Lumps[i].Position + Lumps[i].LumpSize > wadSize || Lumps[i].Position < 0 || Lumps[i].LumpSize < 0) + { + if (Lumps[i].LumpSize != 0) + { + Printf(PRINT_HIGH, "%s: Lump %s contains invalid positioning info and will be ignored\n", Filename, Lumps[i].Name); + Lumps[i].Name[0] = 0; + } + Lumps[i].LumpSize = Lumps[i].Position = 0; + } } delete[] fileinfo;