Skip to content

Commit

Permalink
fix: prevent npe by handling checking error in NewAnalysis call (#1365)
Browse files Browse the repository at this point in the history
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 <danielclark@google.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
  • Loading branch information
pintohutch and AlexsJones authored Jan 31, 2025
1 parent 990d723 commit 83672fa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/server/analyze/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 83672fa

Please sign in to comment.