Skip to content

Commit c31b803

Browse files
authored
Merge pull request #578 from replicatedhq/emosbaugh/sc-48809/analyze-api-fromanalyzerresult-invalid-memory
filter nil analyzer results to prevent panic
2 parents 249e52d + 84b4080 commit c31b803

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pkg/analyze/download.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ func AnalyzeLocal(localBundlePath string, analyzers []*troubleshootv1beta2.Analy
3838
continue
3939
}
4040

41-
if analyzeResult != nil {
42-
analyzeResults = append(analyzeResults, analyzeResult...)
41+
// Filter nil results to prevent panic
42+
for _, r := range analyzeResult {
43+
if r != nil {
44+
analyzeResults = append(analyzeResults, r)
45+
}
4346
}
4447
}
4548

pkg/convert/supportbundle.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ func FromAnalyzerResult(input []*analyze.AnalyzeResult) []*Result {
6969

7070
result := make([]*Result, 0)
7171
for _, i := range input {
72+
// Continue on nil result to prevent panic
73+
if i == nil {
74+
continue
75+
}
7276
name := reg.ReplaceAllString(strings.ToLower(i.Title), ".")
7377
r := &Result{
7478
Meta: Meta{

0 commit comments

Comments
 (0)