Browse Source

Ensure FindInsertNode only return -1, 0 or +1

git-svn-id: trunk@38788 -
pierre 7 years ago
parent
commit
036560010f
1 changed files with 3 additions and 0 deletions
  1. 3 0
      packages/rtl-generics/src/generics.collections.pas

+ 3 - 0
packages/rtl-generics/src/generics.collections.pas

@@ -2875,12 +2875,15 @@ begin
     Result := Compare(ANode.Key,AInsertNode.Key);
     Result := Compare(ANode.Key,AInsertNode.Key);
     if Result < 0 then
     if Result < 0 then
     begin
     begin
+      Result:=-1;
       if AInsertNode.Left = nil then
       if AInsertNode.Left = nil then
         Exit;
         Exit;
       AInsertNode := AInsertNode.Left;
       AInsertNode := AInsertNode.Left;
     end
     end
     else
     else
     begin
     begin
+      if Result > 0 then
+        Result:=1;
       if AInsertNode.Right = nil then
       if AInsertNode.Right = nil then
         Exit;
         Exit;
       AInsertNode := AInsertNode.Right;
       AInsertNode := AInsertNode.Right;