Skip to content

Commit

Permalink
fix: Copy to an invalid addr but can set is not effective.
Browse files Browse the repository at this point in the history
  • Loading branch information
倪振贤 committed Jun 21, 2022
1 parent 71e2b36 commit 7afe0ac
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
}
to = reflect.New(toPtr.Type().Elem())
toPtr.Set(to)
// reindirect
if to = indirect(reflect.ValueOf(toValue)); !to.CanAddr() {
return ErrInvalidCopyDestination
}
}

// Return is from value is invalid
Expand Down

0 comments on commit 7afe0ac

Please sign in to comment.