osbuild: check if result objects are nil in Write()
Before dereferencing the method receiver in Write(), check if the object is nil and return early. Fixes #2002 Signed-off-by: Achilleas Koutsou <achilleas@koutsou.net>
This commit is contained in:
parent
42d7979d65
commit
7f8a1b314a
2 changed files with 4 additions and 2 deletions
|
|
@ -81,8 +81,9 @@ func (result *StageResult) UnmarshalJSON(data []byte) error {
|
|||
}
|
||||
|
||||
func (cr *Result) Write(writer io.Writer) error {
|
||||
if cr.Build == nil && len(cr.Stages) == 0 && cr.Assembler == nil {
|
||||
if cr == nil || (cr.Build == nil && len(cr.Stages) == 0 && cr.Assembler == nil) {
|
||||
fmt.Fprintf(writer, "The compose result is empty.\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
if cr.Build != nil {
|
||||
|
|
|
|||
|
|
@ -201,8 +201,9 @@ func (res *Result) fromV1(resv1 osbuild1.Result) {
|
|||
}
|
||||
|
||||
func (res *Result) Write(writer io.Writer) error {
|
||||
if res.Log == nil {
|
||||
if res == nil || res.Log == nil {
|
||||
fmt.Fprintf(writer, "The compose result is empty.\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
// The pipeline results don't have a stable order
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue