Default conversion for byte slices is incorrect

Nil slices are getting allocated, which is incorrect and changes
behavior in some cases.

   []byte(nil) -> []byte(nil)
pull/6/head
Clayton Coleman 2016-04-17 21:20:50 -04:00
parent e81663c824
commit 2f59744d53
1 changed files with 4 additions and 0 deletions

View File

@ -116,6 +116,10 @@ func (c *Converter) DefaultMeta(t reflect.Type) (FieldMatchingFlags, *Meta) {
// Convert_Slice_byte_To_Slice_byte prevents recursing into every byte
func Convert_Slice_byte_To_Slice_byte(in *[]byte, out *[]byte, s Scope) error {
if *in == nil {
*out = nil
return nil
}
*out = make([]byte, len(*in))
copy(*out, *in)
return nil