🐛 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;
|
function TAnimDataProvider.GetData(AID, AOffset: Integer): TAnimData;
|
||||||
begin
|
begin
|
||||||
|
if (AID < 0) or (AID >= Length(FAnimData)) then
|
||||||
|
raise Exception.CreateFmt('Invalid animdata ID %d', [AID]);
|
||||||
Result := FAnimData[AID];
|
Result := FAnimData[AID];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -114,6 +116,8 @@ end;
|
|||||||
|
|
||||||
procedure TAnimDataProvider.SetData(AID, AOffset: Integer; ABlock: TMulBlock);
|
procedure TAnimDataProvider.SetData(AID, AOffset: Integer; ABlock: TMulBlock);
|
||||||
begin
|
begin
|
||||||
|
if (AID < 0) or (AID >= Length(FAnimData)) then
|
||||||
|
raise Exception.CreateFmt('Invalid animdata ID %d', [AID]);
|
||||||
FreeAndNil(FAnimData[AID]);
|
FreeAndNil(FAnimData[AID]);
|
||||||
FAnimData[AID] := TAnimData(ABlock.Clone);
|
FAnimData[AID] := TAnimData(ABlock.Clone);
|
||||||
|
|
||||||
@@ -126,6 +130,8 @@ end;
|
|||||||
|
|
||||||
function TAnimDataProvider.GetBlock(AID: Integer): TAnimData;
|
function TAnimDataProvider.GetBlock(AID: Integer): TAnimData;
|
||||||
begin
|
begin
|
||||||
|
if (AID < 0) or (AID >= Length(FAnimData)) then
|
||||||
|
raise Exception.CreateFmt('Invalid animdata ID %d', [AID]);
|
||||||
Result := FAnimData[AID].Clone;
|
Result := FAnimData[AID].Clone;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user