Преглед изворни кода

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

git-svn-id: trunk@36942 -
svenbarth пре 8 година
родитељ
комит
c45f738081
1 измењених фајлова са 4 додато и 1 уклоњено
  1. 4 1
      rtl/inc/dynarr.inc

+ 4 - 1
rtl/inc/dynarr.inc

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