🐛 Validate animation data lookups against the entry count

Out-of-range IDs indexed the entry array unchecked and corrupted
memory instead of failing.
This commit is contained in:
2026-11-15 22:06:51 +01:00
parent 32b8d99f3e
commit d3045de064
+6
View File
@@ -93,6 +93,8 @@ end;
function TAnimDataProvider.GetData(AID, AOffset: Integer): TAnimData;
begin
if (AID < 0) or (AID >= Length(FAnimData)) then
raise Exception.CreateFmt('Invalid animdata ID %d', [AID]);
Result := FAnimData[AID];
end;
@@ -114,6 +116,8 @@ end;
procedure TAnimDataProvider.SetData(AID, AOffset: Integer; ABlock: TMulBlock);
begin
if (AID < 0) or (AID >= Length(FAnimData)) then
raise Exception.CreateFmt('Invalid animdata ID %d', [AID]);
FreeAndNil(FAnimData[AID]);
FAnimData[AID] := TAnimData(ABlock.Clone);
@@ -126,6 +130,8 @@ end;
function TAnimDataProvider.GetBlock(AID: Integer): TAnimData;
begin
if (AID < 0) or (AID >= Length(FAnimData)) then
raise Exception.CreateFmt('Invalid animdata ID %d', [AID]);
Result := FAnimData[AID].Clone;
end;