unmarshal: make copy of non addressable values (#576)
When unmarshaling into a nested struct in a map, the value is not addressable. In that case, make a copy of it and modify it instead. Fixes #575
This commit is contained in:
@@ -408,6 +408,12 @@ func (d *decoder) handleKeyPart(key ast.Iterator, v reflect.Value, nextFn handle
|
||||
mv = makeFn()
|
||||
}
|
||||
set = true
|
||||
} else if !mv.CanAddr() {
|
||||
t := v.Type().Elem()
|
||||
oldmv := mv
|
||||
mv = reflect.New(t).Elem()
|
||||
mv.Set(oldmv)
|
||||
set = true
|
||||
}
|
||||
|
||||
x, err := nextFn(key, mv)
|
||||
|
||||
Reference in New Issue
Block a user