Skip to content

Commit

Permalink
fix(config): Check err when parsing config to avoid segfault
Browse files Browse the repository at this point in the history
If loading the config has an error (for example: it contains an unknown field), the OptLoadConfigFile function needs to return an error, otherwise later Options will have a nil pointer for the config, causing them to segfault.
  • Loading branch information
dustmop committed May 7, 2019
1 parent 43a4b2e commit f88e6e6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ func OptLoadConfigFile(path string) Option {
}

o.Cfg, err = config.ReadFromFile(path)
if err != nil {
return err
}
return nil
}
}
Expand Down

0 comments on commit f88e6e6

Please sign in to comment.