Recent

Author Topic: [SOLVED] StringToHex might not return a result  (Read 621 times)

lagprogramming

  • Sr. Member
  • ****
  • Posts: 390
[SOLVED] StringToHex might not return a result
« on: August 11, 2023, 08:22:34 pm »
packages/fcl-hash/src/fphashutils.pp has the following function
Code: Pascal  [Select][+][-]
  1. function StringToHex(const s: ansistring): ansistring;
  2. begin
  3.   if s='' then exit;
  4.   BytesToHexStr(Result,@s[1],length(s));
  5. end;
The code of this function might not assign a result.
« Last Edit: August 12, 2023, 01:26:47 pm by lagprogramming »

domasz

  • Sr. Member
  • ****
  • Posts: 320
Re: StringToHex might not return a result
« Reply #1 on: August 11, 2023, 08:28:17 pm »
Seems someone forgot 3 chars
Code: Pascal  [Select][+][-]
  1.     function StringToHex(const s: ansistring): ansistring;
  2.     begin
  3.       if s='' then exit(s);
  4.       BytesToHexStr(Result,@s[1],length(s));
  5.     end;
« Last Edit: August 11, 2023, 08:30:03 pm by domasz »

lagprogramming

  • Sr. Member
  • ****
  • Posts: 390
Re: StringToHex might not return a result
« Reply #2 on: August 11, 2023, 08:33:15 pm »
Seems someone forgot 3 chars
Code: Pascal  [Select][+][-]
  1.     function StringToHex(const s: ansistring): ansistring;
  2.     begin
  3.       if s='' then exit(s);
  4.       BytesToHexStr(Result,@s[1],length(s));
  5.     end;
Maybe 4: :-\ exit('');
Edit: Should this function be allowed to return an empty string?  :-\ We'll see.
« Last Edit: August 11, 2023, 08:36:33 pm by lagprogramming »

Thaddy

  • Hero Member
  • *****
  • Posts: 13262
Re: StringToHex might not return a result
« Reply #3 on: August 11, 2023, 08:38:57 pm »
That is flawed indeed, use syutils and the helper ToHexString.
I actually get compliments for being rude... (well, Dutch, but that is the same)

AlexTP

  • Hero Member
  • *****
  • Posts: 2292
    • UVviewsoft

 

TinyPortal © 2005-2018