Skip to content

Commit

Permalink
Merge pull request #578 from replicatedhq/emosbaugh/sc-48809/analyze-…
Browse files Browse the repository at this point in the history
…api-fromanalyzerresult-invalid-memory

filter nil analyzer results to prevent panic
  • Loading branch information
emosbaugh committed May 23, 2022
2 parents 249e52d + 84b4080 commit c31b803
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/analyze/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ func AnalyzeLocal(localBundlePath string, analyzers []*troubleshootv1beta2.Analy
continue
}

if analyzeResult != nil {
analyzeResults = append(analyzeResults, analyzeResult...)
// Filter nil results to prevent panic
for _, r := range analyzeResult {
if r != nil {
analyzeResults = append(analyzeResults, r)
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/convert/supportbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func FromAnalyzerResult(input []*analyze.AnalyzeResult) []*Result {

result := make([]*Result, 0)
for _, i := range input {
// Continue on nil result to prevent panic
if i == nil {
continue
}
name := reg.ReplaceAllString(strings.ToLower(i.Title), ".")
r := &Result{
Meta: Meta{
Expand Down

0 comments on commit c31b803

Please sign in to comment.