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:
parent
3c41a7ca1e
commit
a111635908
|
@ -204,8 +204,8 @@ func TestConfigValidate_table(t *testing.T) {
|
||||||
{
|
{
|
||||||
"nested types in variable default",
|
"nested types in variable default",
|
||||||
"validate-var-nested",
|
"validate-var-nested",
|
||||||
true,
|
false,
|
||||||
"ERROR",
|
"",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,6 +206,12 @@ func (w *interpolationWalker) Primitive(v reflect.Value) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *interpolationWalker) replaceCurrent(v reflect.Value) {
|
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]
|
c := w.cs[len(w.cs)-2]
|
||||||
switch c.Kind() {
|
switch c.Kind() {
|
||||||
case reflect.Map:
|
case reflect.Map:
|
||||||
|
|
Loading…
Reference in New Issue