Skip to content

Commit

Permalink
make sure to deep copy the field indices
Browse files Browse the repository at this point in the history
  • Loading branch information
alexflint committed Jan 24, 2020
1 parent 7116188 commit 2cc1f13
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ func walkFields(t reflect.Type, visit func(field reflect.StructField, owner refl
func walkFieldsImpl(t reflect.Type, visit func(field reflect.StructField, owner reflect.Type) bool, path []int) {
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
field.Index = append(path, i)
field.Index = make([]int, len(path)+1)
copy(field.Index, append(path, i))
expand := visit(field, t)
if expand && field.Type.Kind() == reflect.Struct {
var subpath []int
Expand Down

0 comments on commit 2cc1f13

Please sign in to comment.