Skip to content

Commit 72ea4b0

Browse files
authored
fix(spdx): init pkgFilePaths map for all formats (#8380)
1 parent 9637286 commit 72ea4b0

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/sbom/spdx/unmarshal.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ func (s *SPDX) UnmarshalJSON(b []byte) error {
5353
if s.BOM == nil {
5454
s.BOM = core.NewBOM(core.Options{})
5555
}
56-
if s.pkgFilePaths == nil {
57-
s.pkgFilePaths = make(map[common.ElementID]string)
58-
}
5956

6057
spdxDocument, err := json.Read(bytes.NewReader(b))
6158
if err != nil {
@@ -71,6 +68,10 @@ func (s *SPDX) UnmarshalJSON(b []byte) error {
7168
func (s *SPDX) unmarshal(spdxDocument *spdx.Document) error {
7269
s.trivySBOM = s.isTrivySBOM(spdxDocument)
7370

71+
if s.pkgFilePaths == nil {
72+
s.pkgFilePaths = make(map[common.ElementID]string)
73+
}
74+
7475
// Parse files and find file paths for packages
7576
s.parseFiles(spdxDocument)
7677

0 commit comments

Comments
 (0)