Forum > FPC development

[SOLVED] StringToHex might not return a result

(1/1)

lagprogramming:
packages/fcl-hash/src/fphashutils.pp has the following function

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function StringToHex(const s: ansistring): ansistring;begin  if s='' then exit;  BytesToHexStr(Result,@s[1],length(s));end;The code of this function might not assign a result.

domasz:
Seems someone forgot 3 chars

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    function StringToHex(const s: ansistring): ansistring;    begin      if s='' then exit(s);      BytesToHexStr(Result,@s[1],length(s));    end;

lagprogramming:

--- Quote from: domasz on August 11, 2023, 08:28:17 pm ---Seems someone forgot 3 chars

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    function StringToHex(const s: ansistring): ansistring;    begin      if s='' then exit(s);      BytesToHexStr(Result,@s[1],length(s));    end;
--- End quote ---
Maybe 4: :-\ exit('');
Edit: Should this function be allowed to return an empty string?  :-\ We'll see.

Thaddy:
That is flawed indeed, use syutils and the helper ToHexString.

AlexTP:
Posted to https://gitlab.com/freepascal.org/fpc/source/-/issues/40388

Navigation

[0] Message Index

Go to full version