diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-01-18 17:10:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-18 17:10:51 +0100 |
commit | a2ab36d0d115718b5d08ccca9ff567de1d3db20a (patch) | |
tree | 1fd428ff173e0678a821501b8e478bb7a946e7f0 | |
parent | 7f19e5fb23b785399d49166171b6af7a34edf437 (diff) | |
parent | fc52b0423b67cc4a2caafc5dab48832d5bedc1ab (diff) | |
download | podman-a2ab36d0d115718b5d08ccca9ff567de1d3db20a.tar.gz podman-a2ab36d0d115718b5d08ccca9ff567de1d3db20a.tar.bz2 podman-a2ab36d0d115718b5d08ccca9ff567de1d3db20a.zip |
Merge pull request #2185 from mheon/specfromstate_fix
Do not unmarshal into c.config.Spec
-rw-r--r-- | libpod/container.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libpod/container.go b/libpod/container.go index 95f7a2972..b5f6a29ba 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -415,14 +415,15 @@ func (c *Container) Spec() *spec.Spec { // config does not exist (e.g., because the container was never started) return // the spec from the config. func (c *Container) specFromState() (*spec.Spec, error) { - spec := c.config.Spec + returnSpec := c.config.Spec if f, err := os.Open(c.state.ConfigPath); err == nil { + returnSpec = new(spec.Spec) content, err := ioutil.ReadAll(f) if err != nil { return nil, errors.Wrapf(err, "error reading container config") } - if err := json.Unmarshal([]byte(content), &spec); err != nil { + if err := json.Unmarshal([]byte(content), &returnSpec); err != nil { return nil, errors.Wrapf(err, "error unmarshalling container config") } } else { @@ -432,7 +433,7 @@ func (c *Container) specFromState() (*spec.Spec, error) { } } - return spec, nil + return returnSpec, nil } // ID returns the container's ID |