🚨 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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user