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