worker: check field exists before accessing it

Before accessing a field of the `OSBuildOutput`, which itself is a
field of the `osbuildKojiResults` struct, check if it is actually
is set (non-nill), otherwise dereferencing it will crash the
worker.
The field will be null if osbuild has not been invoked at all or
if osbuild crashed or refused to accept the input.
This commit is contained in:
Christian Kellner 2022-01-26 17:13:56 +00:00 committed by Tom Gundersen
parent 46b2c2e31d
commit da1537dee6

View file

@ -233,7 +233,9 @@ func hasFailedDependency(kojiInitResult worker.KojiInitJobResult, osbuildKojiRes
}
for _, r := range osbuildKojiResults {
if !r.OSBuildOutput.Success || r.JobError != nil {
// No `OSBuildOutput` implies failure: either osbuild crashed or
// rejected the input (manifest or command line arguments)
if r.OSBuildOutput == nil || !r.OSBuildOutput.Success || r.JobError != nil {
return true
}
}