mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-16 21:56:40 -05:00
Fix panics by disallowing explicitly-defined null modules in config
This commit is contained in:
parent
38677aaa58
commit
6000855c82
1 changed files with 9 additions and 0 deletions
|
@ -100,6 +100,15 @@ func (ctx Context) LoadModule(name string, rawMsg json.RawMessage) (interface{},
|
|||
}
|
||||
}
|
||||
|
||||
if val == nil {
|
||||
// returned module values are almost always type-asserted
|
||||
// before being used, so a nil value would panic; and there
|
||||
// is no good reason to explicitly declare null modules in
|
||||
// a config; it might be because the user is trying to
|
||||
// achieve a result they aren't expecting, which is a smell
|
||||
return nil, fmt.Errorf("module value cannot be null")
|
||||
}
|
||||
|
||||
if prov, ok := val.(Provisioner); ok {
|
||||
err := prov.Provision(ctx)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue