Skip to content

Commit e222e66

Browse files
author
Zhou Hao
authored
Merge pull request #641 from kinvolk/dongsu/fix-panic-multierror
validation: fix nil dereference when handling multierror in hooks_stdin
2 parents e93f712 + cd3faf9 commit e222e66

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

validation/hooks_stdin.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,13 @@ func main() {
151151
}
152152
for _, file := range []string{"prestart", "poststart", "poststop"} {
153153
errs := stdinStateCheck(outputDir, file, expectedState)
154-
util.SpecErrorOK(t, errs.ErrorOrNil() == nil, specerror.NewError(specerror.PosixHooksStateToStdin, fmt.Errorf("the state of the container MUST be passed to %q hook over stdin", file), rspecs.Version), errors.New(errs.Error()))
154+
var newError error
155+
if errs == nil {
156+
newError = errors.New("")
157+
} else {
158+
newError = errors.New(errs.Error())
159+
}
160+
util.SpecErrorOK(t, errs.ErrorOrNil() == nil, specerror.NewError(specerror.PosixHooksStateToStdin, fmt.Errorf("the state of the container MUST be passed to %q hook over stdin", file), rspecs.Version), newError)
155161
}
156162

157163
t.AutoPlan()

0 commit comments

Comments
 (0)