Skip to content

Commit

Permalink
Fix #1101
Browse files Browse the repository at this point in the history
Initialize the result of the function IsHash to false. In some systems ramdonly if exits before assign a value to Result returns true (what it is wrong, because the default value is false)
  • Loading branch information
antekgla committed Mar 22, 2018
1 parent 261aac9 commit f53c87c
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -945,20 +945,21 @@ function WndCallback(Ahwnd: HWND; uMsg: UINT; wParam: WParam; lParam: LParam):LR

{$endif windows}

function IsHash(Hash: String): boolean;
var i: integer;
begin
if Hash = '' then exit;
if Length(Hash) = 32 then // possible base32 encoded hash
try
Hash:=StrToHex(Base32Decode(UpperCase(Hash)));
except
exit;
end;
if Length(Hash) <> 40 then exit;
Result := true;
for i := 1 to 40 do if not (Hash[i] in ['a' .. 'f', 'A'..'F', '0'..'9']) then Result := false;
end;
function IsHash(Hash: String): boolean;
var i: integer;
begin
Result := false;
if Hash = '' then exit;
if Length(Hash) = 32 then // possible base32 encoded hash
try
Hash:=StrToHex(Base32Decode(UpperCase(Hash)));
except
exit;
end;
if Length(Hash) <> 40 then exit;
Result := true;
for i := 1 to 40 do if not (Hash[i] in ['a' .. 'f', 'A'..'F', '0'..'9']) then Result := false;
end;

procedure TMainForm.ReadLocalFolderWatch;
var
Expand Down

0 comments on commit f53c87c

Please sign in to comment.