#1 mORMot 2 » Bug when hashing long unicode strings » 2025-01-29 21:24:38

rpa
Replies: 1

With certain long keys the following code throws AV

  s := StringOfChar('x', 222);
  dict := Collections.NewKeyValue<string,integer>;
  dict.TryGetValue(s, v);

Debugging it it looks like that the HashSynUnicode code is missing a defererence here:

    if l > 255 then // no need to hash too big a content
    begin
      Item := @PAnsiChar(Item)[l - 256]; // hash ending of string
      l := 256;
    end;

It should be PAnsiChar(Item^), the current code hashes the memory at an offset relative to the string reference, not the start of the string content (with strings longer than 127 chars).

Board footer

Powered by FluxBB