libcontainer: fix potential panic if spec.Process is nil
for the code logic, pointer 'spec.Process' should be judge first
to avoid panic.
@@ -251,11 +251,10 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
}
}
}
- if spec.Process.SelinuxLabel != "" {
- config.ProcessLabel = spec.Process.SelinuxLabel
- }
if spec.Process != nil {
config.OomScoreAdj = spec.Process.OOMScoreAdj
+ if spec.Process.SelinuxLabel != "" {
+ config.ProcessLabel = spec.Process.SelinuxLabel
}
if spec.Process.Capabilities != nil {
config.Capabilities = &configs.Capabilities{
@@ -266,6 +265,7 @@ func CreateLibcontainerConfig(opts *CreateOpts) (*configs.Config, error) {
Ambient: spec.Process.Capabilities.Ambient,
}
}
+ }
createHooks(spec, config)
config.Version = specs.Version
return config, nil
