Issue #1111: Add two safety checks in TAppSettings.GetSessionNames, trying to blindly fix some endless recursion happening on user nami0309's system when starting HeidiSQL

This commit is contained in:
Ansgar Becker
2020-08-03 12:07:41 +02:00
parent f2f7bdaf5f
commit 1529b32a2d

View File

@@ -4116,10 +4116,15 @@ begin
Result := TStringList.Create;
FRegistry.GetKeyNames(Result);
for i:=Result.Count-1 downto 0 do begin
FRegistry.OpenKey(CurPath+'\'+Result[i], False);
if FRegistry.ValueExists(GetValueName(asSessionFolder)) then begin
Folders.Add(Result[i]);
Result.Delete(i);
// Issue #1111 describes a recursive endless loop, which may be caused by an empty key name here?
if Result[i].IsEmpty then
Continue;
// ... may also be caused by some non accessible key. Check result of .OpenKey before looking for "Folder" value:
if FRegistry.OpenKey(CurPath+'\'+Result[i], False) then begin
if FRegistry.ValueExists(GetValueName(asSessionFolder)) then begin
Folders.Add(Result[i]);
Result.Delete(i);
end;
end;
end;
end;