* fix DynArrayIndex(): as the last typeinfo entry is no longer a dynamic array the elSize needs to be remembered

git-svn-id: trunk@36942 -
This commit is contained in:
svenbarth 2017-08-20 15:15:25 +00:00
parent 9291fb1eed
commit c45f738081

View File

@ -673,6 +673,7 @@ function IsDynArrayRectangular(a: Pointer; typeInfo: Pointer): Boolean;
function DynArrayIndex(a: Pointer; const indices: array of SizeInt; typeInfo: Pointer): Pointer; function DynArrayIndex(a: Pointer; const indices: array of SizeInt; typeInfo: Pointer): Pointer;
var var
i,h: sizeint; i,h: sizeint;
elsize: sizeuint;
begin begin
h:=High(indices); h:=High(indices);
for i:=0 to h do for i:=0 to h do
@ -682,6 +683,8 @@ function DynArrayIndex(a: Pointer; const indices: array of SizeInt; typeInfo: Po
{ skip kind and name } { skip kind and name }
typeInfo:=(typeInfo+2+PByte(typeInfo)[1]); typeInfo:=(typeInfo+2+PByte(typeInfo)[1]);
{ store the last element size for the index calculation }
elsize:=pdynarraytypedata(typeInfo)^.elSize;
{ element type info} { element type info}
{$ifdef VER3_0} {$ifdef VER3_0}
typeInfo:=pdynarraytypedata(typeInfo)^.elType2; typeInfo:=pdynarraytypedata(typeInfo)^.elType2;
@ -696,7 +699,7 @@ function DynArrayIndex(a: Pointer; const indices: array of SizeInt; typeInfo: Po
{ skip kind and name } { skip kind and name }
typeInfo:=(typeInfo+2+PByte(typeInfo)[1]); typeInfo:=(typeInfo+2+PByte(typeInfo)[1]);
result:=@(PByte(a)[indices[h]*pdynarraytypedata(typeInfo)^.elSize]); result:=@(PByte(a)[indices[h]*elsize]);
end; end;
{ obsolete but needed for bootstrapping } { obsolete but needed for bootstrapping }