Merge pull request #622 from rajasec/loadspec-return

Handling error condition in loadspec
This commit is contained in:
Mrunal Patel 2016-03-08 11:00:25 -08:00
commit 4155b68a24
1 changed files with 2 additions and 2 deletions

View File

@ -220,12 +220,12 @@ func loadSpec(cPath string) (spec *specs.LinuxSpec, err error) {
if os.IsNotExist(err) { if os.IsNotExist(err) {
return nil, fmt.Errorf("JSON specification file %s not found", cPath) return nil, fmt.Errorf("JSON specification file %s not found", cPath)
} }
return spec, err return nil, err
} }
defer cf.Close() defer cf.Close()
if err = json.NewDecoder(cf).Decode(&spec); err != nil { if err = json.NewDecoder(cf).Decode(&spec); err != nil {
return spec, err return nil, err
} }
return spec, validateSpec(spec) return spec, validateSpec(spec)
} }