Decode: assigned empty struct to empty defined sections (#879)

Co-authored-by: Thomas Pelletier <thomas@pelletier.codes>
This commit is contained in:
David Barroso
2023-07-12 16:53:17 +02:00
committed by GitHub
parent 60e4af8cca
commit e183db7e69
3 changed files with 105 additions and 2 deletions
+2 -2
View File
@@ -1170,10 +1170,10 @@ func initAndDereferencePointer(v reflect.Value) reflect.Value {
// Same as reflect.Value.FieldByIndex, but creates pointers if needed.
func fieldByIndex(v reflect.Value, path []int) reflect.Value {
for i, x := range path {
for _, x := range path {
v = v.Field(x)
if i < len(path)-1 && v.Kind() == reflect.Ptr {
if v.Kind() == reflect.Ptr {
if v.IsNil() {
v.Set(reflect.New(v.Type().Elem()))
}