Fixed: in some cases the editor could stuck in an infinite loop when searching for wad lumps.

This commit is contained in:
spherallic 2023-01-08 13:14:41 +01:00
parent 4222e06c71
commit 5fd95f703d

View file

@ -452,15 +452,16 @@ namespace CodeImp.DoomBuilder.IO
// This finds a lump by name, returns -1 when not found
public int FindLumpIndex(string name, int start, int end)
{
if(name.Length > 8) return -1;//mxd. Can't be here. Go away!
if(name.Length > 8 || lumps.Count == 0 || start > lumps.Count - 1) return -1;//mxd. Can't be here. Go away!
long longname = Lump.MakeLongName(name);
// Fix end when it exceeds length
if(end > (lumps.Count - 1)) end = lumps.Count - 1;
// Fix start/end when they exceed safe bounds
start = Math.Max(start, 0);
end = General.Clamp(end, 0, lumps.Count - 1);
// Loop through the lumps
for(int i = start; i <= end; i++)
for (int i = start; i <= end; i++)
{
// Check if the lump name matches
if(lumps[i].LongName == longname)