Skip to content

Commit 18c5678

Browse files
author
zhouhao
committed
validate: fix spec.Process nil deference
Signed-off-by: zhouhao <[email protected]>
1 parent 5753b3a commit 18c5678

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

validate/validate.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ func (v *Validator) CheckAll() (msgs []string) {
102102
msgs = append(msgs, v.CheckMounts()...)
103103
msgs = append(msgs, v.CheckProcess()...)
104104
msgs = append(msgs, v.CheckHooks()...)
105-
if v.spec.Linux != nil {
106-
msgs = append(msgs, v.CheckLinux()...)
107-
}
105+
msgs = append(msgs, v.CheckLinux()...)
108106

109107
return
110108
}
@@ -211,6 +209,10 @@ func checkEventHooks(hookType string, hooks []rspec.Hook, hostSpecific bool) (ms
211209
func (v *Validator) CheckProcess() (msgs []string) {
212210
logrus.Debugf("check process")
213211

212+
if v.spec.Process == nil {
213+
return
214+
}
215+
214216
process := v.spec.Process
215217
if !filepath.IsAbs(process.Cwd) {
216218
msgs = append(msgs, fmt.Sprintf("cwd %q is not an absolute path", process.Cwd))
@@ -425,6 +427,10 @@ func (v *Validator) CheckPlatform() (msgs []string) {
425427
func (v *Validator) CheckLinux() (msgs []string) {
426428
logrus.Debugf("check linux")
427429

430+
if v.spec.Linux == nil {
431+
return
432+
}
433+
428434
var typeList = map[rspec.LinuxNamespaceType]struct {
429435
num int
430436
newExist bool

0 commit comments

Comments
 (0)