Fix panic in interpolate_walk

Verify that we have enough containers in the stack to look for a map in
replaceCurrent.
This commit is contained in:
James Bardin 2017-03-07 15:33:39 -05:00
parent 3c41a7ca1e
commit a111635908
2 changed files with 8 additions and 2 deletions

View File

@ -204,8 +204,8 @@ func TestConfigValidate_table(t *testing.T) {
{
"nested types in variable default",
"validate-var-nested",
true,
"ERROR",
false,
"",
},
}

View File

@ -206,6 +206,12 @@ func (w *interpolationWalker) Primitive(v reflect.Value) error {
}
func (w *interpolationWalker) replaceCurrent(v reflect.Value) {
// if we don't have at least 2 values, we're not going to find a map, but
// we could panic.
if len(w.cs) < 2 {
return
}
c := w.cs[len(w.cs)-2]
switch c.Kind() {
case reflect.Map: