From 83672fa768887dd1c6f4dc12a92c3444f100c4f6 Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Fri, 31 Jan 2025 09:26:35 -0500 Subject: [PATCH] fix: prevent npe by handling checking error in NewAnalysis call (#1365) If there is an issue in creating the Analysis config when calling analysis.NewAnalysis, then we want to check before assigning the context to a potentially nil pointer. Signed-off-by: Danny Clark Co-authored-by: Alex Jones --- pkg/server/analyze/analyze.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/server/analyze/analyze.go b/pkg/server/analyze/analyze.go index 0d61682abd..517d2a9a86 100644 --- a/pkg/server/analyze/analyze.go +++ b/pkg/server/analyze/analyze.go @@ -34,10 +34,10 @@ func (h *Handler) Analyze(ctx context.Context, i *schemav1.AnalyzeRequest) ( []string{}, //TODO: add custom http headers in server mode false, // with stats disable ) - config.Context = ctx // Replace context for correct timeouts. if err != nil { return &schemav1.AnalyzeResponse{}, err } + config.Context = ctx // Replace context for correct timeouts. defer config.Close() if config.CustomAnalyzersAreAvailable() {