Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/protocol/LSP.Basic.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,9 @@ procedure TDiagnostic.Assign(Source : TPersistent);
Severity:=Src.severity;
Code:=Src.Code;
self.Source:=Src.Source;
if Src.source.HasValue then
// source is a TOptionalString class and stays nil when unset;
// guard before dereferencing to avoid an access violation.
if Assigned(Src.source) and Src.source.HasValue then
Message:=Src.Source.Value;
end
else
Expand Down
11 changes: 9 additions & 2 deletions src/serverprotocol/PasLS.General.pas
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,20 @@ procedure TInitialize.ShowConfigStatus(Params: TInitializeParams; CodeToolsOptio
I: Integer;
FPCOptions: TStringArray;
begin
if Params.clientInfo.version.HasValue then
// clientInfo and its version are optional in the LSP spec; both may be
// nil here (TOptionalString is a class that stays nil when the client
// omits the field), so guard before dereferencing.
if Assigned(Params.clientInfo) and Assigned(Params.clientInfo.version)
and Params.clientInfo.version.HasValue then
clientInfoVersion := ' ' + Params.clientInfo.version.Value
else
clientInfoVersion := '';

DoLog(kStatusPrefix+'Server: ' + {$INCLUDE %DATE%});
DoLog(kStatusPrefix+'Client: ' + Params.clientInfo.name + clientInfoVersion);
if Assigned(Params.clientInfo) then
DoLog(kStatusPrefix+'Client: ' + Params.clientInfo.name + clientInfoVersion)
else
DoLog(kStatusPrefix+'Client: <unknown>');

DoLog(kStatusPrefix+'FPCPath: ' + CodeToolsOptions.FPCPath);
DoLog(kStatusPrefix+'FPCSrcDir: ' + CodeToolsOptions.FPCSrcDir);
Expand Down