Permalink
Browse files

! dictionary resize was called twice in a row

test case:

dic := TDictionary.Create;
try
for i := 1 to 63 do
dic.Add(IntToStr(i));
// next two calls will both trigger Resize
dic.Add('64');
dic.Add('65');
for i := 66 to 127 do
dic.Add(IntToStr(i));
// next two calls will both trigger Resize
dic.Add('128');
dic.Add('129');
finally FreeAndNil(dic); end;
  • Loading branch information...
gabr42 committed Mar 22, 2017
1 parent 0963ecf commit ccaeff1e88f76163b8d02cc361e846d748af9f41
Showing with 3 additions and 1 deletion.
  1. +3 −1 OmniXML_Dictionary.pas
View
@@ -49,6 +49,7 @@ TDictionary = class
{$ENDIF}
FTextList: TStringList;
FMaxItemsBeforeResize: Integer;
FLastHashSize: Integer;
procedure Resize;
public
constructor Create; reintroduce;
@@ -171,7 +172,8 @@ procedure TDictionary.Resize;
begin
FHashTable.Free;
HashSize := GetGoodHashSize(FTextList.Count);
HashSize := GetGoodHashSize(FLastHashSize+1);
FLastHashSize := HashSize;
{$IFDEF FPC}
FHashTable := TFPHashList.Create;

0 comments on commit ccaeff1

Please sign in to comment.