Fix exception if the BSP we're trying to read is actually too small to read.

This commit is contained in:
wfowler
2018-12-31 15:05:36 -07:00
parent a07c8e86cf
commit bd0a1056f2

View File

@@ -311,6 +311,9 @@ namespace LibBSP {
private MapType GetVersion(bool bigEndian) {
MapType current = MapType.Undefined;
using (FileStream stream = new FileStream(bspFile.FullName, FileMode.Open, FileAccess.Read)) {
if (stream.Length < 4) {
return current;
}
BinaryReader binaryReader = new BinaryReader(stream);
stream.Seek(0, SeekOrigin.Begin);
int num = binaryReader.ReadInt32();