Skip to content

Commit

Permalink
fix: missing error handling when marshalling LicenseChoice to XML
Browse files Browse the repository at this point in the history
Signed-off-by: nscuro <[email protected]>
  • Loading branch information
nscuro committed Jun 22, 2021
1 parent 301ae58 commit 42e12f9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cyclonedx.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,12 @@ func (l LicenseChoice) MarshalXML(e *xml.Encoder, _ xml.StartElement) error {
return e.EncodeElement(l.License, xml.StartElement{Name: xml.Name{Local: "license"}})
} else if l.Expression != "" {
expressionElement := xml.StartElement{Name: xml.Name{Local: "expression"}}
e.EncodeToken(expressionElement)
e.EncodeToken(xml.CharData(l.Expression))
if err := e.EncodeToken(expressionElement); err != nil {
return err
}
if err := e.EncodeToken(xml.CharData(l.Expression)); err != nil {
return err
}
return e.EncodeToken(xml.EndElement{Name: expressionElement.Name})
}

Expand Down

0 comments on commit 42e12f9

Please sign in to comment.