Skip to content

Commit af0ea1e

Browse files
author
Ma Shimiao
authored
Merge pull request #361 from cyphar/hook-nil-deref
validate: fix spec.Hooks nil dereference
2 parents 2f0b832 + b2aabff commit af0ea1e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

validate/validate.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,11 @@ func (v *Validator) CheckPlatform() (msgs []string) {
200200
func (v *Validator) CheckHooks() (msgs []string) {
201201
logrus.Debugf("check hooks")
202202

203-
msgs = append(msgs, checkEventHooks("pre-start", v.spec.Hooks.Prestart, v.HostSpecific)...)
204-
msgs = append(msgs, checkEventHooks("post-start", v.spec.Hooks.Poststart, v.HostSpecific)...)
205-
msgs = append(msgs, checkEventHooks("post-stop", v.spec.Hooks.Poststop, v.HostSpecific)...)
203+
if v.spec.Hooks != nil {
204+
msgs = append(msgs, checkEventHooks("pre-start", v.spec.Hooks.Prestart, v.HostSpecific)...)
205+
msgs = append(msgs, checkEventHooks("post-start", v.spec.Hooks.Poststart, v.HostSpecific)...)
206+
msgs = append(msgs, checkEventHooks("post-stop", v.spec.Hooks.Poststop, v.HostSpecific)...)
207+
}
206208

207209
return
208210
}

0 commit comments

Comments
 (0)