From f88e6e668c42dbc3ebc2ecac8530b45e713b6f8c Mon Sep 17 00:00:00 2001 From: Dustin Long Date: Tue, 7 May 2019 11:51:08 -0400 Subject: [PATCH] fix(config): Check err when parsing config to avoid segfault 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. --- lib/lib.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/lib.go b/lib/lib.go index c5a973fbd..7c10129e3 100644 --- a/lib/lib.go +++ b/lib/lib.go @@ -181,6 +181,9 @@ func OptLoadConfigFile(path string) Option { } o.Cfg, err = config.ReadFromFile(path) + if err != nil { + return err + } return nil } }