summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2017-11-09 15:27:33 -0500
committerMatthew Heon <matthew.heon@gmail.com>2017-11-18 12:58:48 -0500
commit12f19ca013bad5382eec72abf4cf2d5d7c71d3a5 (patch)
tree1dc55bfbd7178791c9c31493cfc4ad811f43f2d2
parent657cb1b7f6be1610d6888acf18bb77027108ea9e (diff)
downloadpodman-12f19ca013bad5382eec72abf4cf2d5d7c71d3a5.tar.gz
podman-12f19ca013bad5382eec72abf4cf2d5d7c71d3a5.tar.bz2
podman-12f19ca013bad5382eec72abf4cf2d5d7c71d3a5.zip
Resolve another segfault
This one cleans up after container creation fails Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
-rw-r--r--libpod/runtime_ctr.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index a8a5b789d..aa8ff7d88 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -19,14 +19,14 @@ type CtrCreateOption func(*Container) error
type ContainerFilter func(*Container) bool
// NewContainer creates a new container from a given OCI config
-func (r *Runtime) NewContainer(spec *spec.Spec, options ...CtrCreateOption) (ctr *Container, err error) {
+func (r *Runtime) NewContainer(spec *spec.Spec, options ...CtrCreateOption) (c *Container, err error) {
r.lock.Lock()
defer r.lock.Unlock()
if !r.valid {
return nil, ErrRuntimeStopped
}
- ctr, err = newContainer(spec)
+ ctr, err := newContainer(spec)
if err != nil {
return nil, err
}
@@ -60,7 +60,7 @@ func (r *Runtime) NewContainer(spec *spec.Spec, options ...CtrCreateOption) (ctr
}
}
defer func() {
- if err != nil {
+ if err != nil && ctr.pod != nil {
if err2 := ctr.pod.removeContainer(ctr); err2 != nil {
logrus.Errorf("Error removing partially-created container from pod %s: %s", ctr.pod.ID(), err2)
}