From 6f0e0cf025dd99ab903e33f8e043d92b28dab4f6 Mon Sep 17 00:00:00 2001 From: nscuro Date: Sat, 14 Sep 2024 12:37:13 +0200 Subject: [PATCH] fix: `nil` pointer dereference during evidence conversion Signed-off-by: nscuro --- convert.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/convert.go b/convert.go index 7dbecb4..3124ce7 100644 --- a/convert.go +++ b/convert.go @@ -195,13 +195,15 @@ func convertEvidence(c *Component, specVersion SpecVersion) { } if specVersion < SpecVersion1_6 { - for i := range *c.Evidence.Occurrences { - occ := &(*c.Evidence.Occurrences)[i] - - occ.Line = nil - occ.Offset = nil - occ.Symbol = "" - occ.AdditionalContext = "" + if c.Evidence.Occurrences != nil { + for i := range *c.Evidence.Occurrences { + occ := &(*c.Evidence.Occurrences)[i] + + occ.Line = nil + occ.Offset = nil + occ.Symbol = "" + occ.AdditionalContext = "" + } } }