From c3dbfd7ce8fc46f7c1fee491006371dbeecd9c21 Mon Sep 17 00:00:00 2001 From: Michito Maeda Date: Wed, 15 Jan 2025 03:41:07 +0900 Subject: [PATCH] Fix nil pointer dereference in workspace capabilities check (#3582) --- private/buf/buflsp/server.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/private/buf/buflsp/server.go b/private/buf/buflsp/server.go index 0616ee8786..524b5bd93c 100644 --- a/private/buf/buflsp/server.go +++ b/private/buf/buflsp/server.go @@ -142,7 +142,12 @@ func (s *server) Initialized( ctx context.Context, params *protocol.InitializedParams, ) error { - if s.initParams.Load().Capabilities.Workspace.DidChangeConfiguration.DynamicRegistration { + workspaceCapabilities := s.initParams.Load().Capabilities.Workspace + if workspaceCapabilities == nil { + return nil + } + didChangeConfiguration := workspaceCapabilities.DidChangeConfiguration + if didChangeConfiguration != nil && didChangeConfiguration.DynamicRegistration { // The error is logged for us by the client wrapper. _ = s.client.RegisterCapability(ctx, &protocol.RegistrationParams{ Registrations: []protocol.Registration{