🚨 Harden the nodraw map loader

A parse error leaked the file handle and negative IDs from a
malformed file indexed the draw bitmap out of bounds.
This commit is contained in:
2026-11-15 22:06:51 +01:00
parent 1335e3f40e
commit fa288fddf8
+6 -1
View File
@@ -1198,6 +1198,7 @@ var
begin
AssignFile(noDrawFile, AFileName);
Reset(noDrawFile);
try
while not EOF(noDrawFile) do
begin
ReadLn(noDrawFile, line);
@@ -1216,6 +1217,8 @@ begin
Inc(id2, $4000);
end;
if id1 < 0 then
id1 := 0;
for i := id1 to id2 do
if i < FDrawMap.Size then
FDrawMap[i] := False;
@@ -1227,13 +1230,15 @@ begin
begin
if line[1] = 'S' then
Inc(id1, $4000);
if id1 < FDrawMap.Size then
if (id1 >= 0) and (id1 < FDrawMap.Size) then
FDrawMap[id1] := False;
end;
end;
end;
end;
finally
CloseFile(noDrawFile);
end;
end;
procedure TLandscape.MoveStatic(AStatic: TStaticItem; AX, AY: Word);