From 8132f4d797fee557d226ddab2ea8a0e197135fff Mon Sep 17 00:00:00 2001 From: Lai Jiangshan Date: Wed, 16 Sep 2015 10:54:53 +0800 Subject: [PATCH] close config file after loaded Signed-off-by: Lai Jiangshan --- spec.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec.go b/spec.go index 5a5184a35..47d448a75 100644 --- a/spec.go +++ b/spec.go @@ -282,6 +282,8 @@ func loadSpec(cPath, rPath string) (spec *specs.LinuxSpec, rspec *specs.LinuxRun } return } + defer cf.Close() + rf, err := os.Open(rPath) if err != nil { if os.IsNotExist(err) { @@ -290,6 +292,7 @@ func loadSpec(cPath, rPath string) (spec *specs.LinuxSpec, rspec *specs.LinuxRun return } defer rf.Close() + if err = json.NewDecoder(cf).Decode(&spec); err != nil { return }