Browse Source

Fix variable i range of values in class function TObject.GetInterfaceEntryByStr(const iidstr : shortstring) : pinterfaceentry;

lag programming 4 months ago
parent
commit
bfaa957df0
1 changed files with 6 additions and 3 deletions
  1. 6 3
      rtl/inc/objpas.inc

+ 6 - 3
rtl/inc/objpas.inc

@@ -1091,7 +1091,7 @@ end;
 
 
       class function TObject.GetInterfaceEntryByStr(const iidstr : shortstring) : pinterfaceentry;
       class function TObject.GetInterfaceEntryByStr(const iidstr : shortstring) : pinterfaceentry;
         var
         var
-          i: longint;
+          i: sizeuint;
           intftable: pinterfacetable;
           intftable: pinterfacetable;
           ovmt: PVmt;
           ovmt: PVmt;
         begin
         begin
@@ -1099,11 +1099,14 @@ end;
           while Assigned(ovmt) and Assigned(ovmt^.vIntfTable) do
           while Assigned(ovmt) and Assigned(ovmt^.vIntfTable) do
           begin
           begin
             intftable:=ovmt^.vIntfTable;
             intftable:=ovmt^.vIntfTable;
-            for i:=0 to intftable^.EntryCount-1 do
+            i:=intftable^.EntryCount;
+            result:=@intftable^.Entries[0];
+            while i>0 do
             begin
             begin
-              result:=@intftable^.Entries[i];
               if assigned(result^.iidstr) and (result^.iidstr^ = iidstr) then
               if assigned(result^.iidstr) and (result^.iidstr^ = iidstr) then
                 Exit;
                 Exit;
+              inc(Result);
+              dec(i);
             end;
             end;
             ovmt := ovmt^.vParent;
             ovmt := ovmt^.vParent;
           end;
           end;