Commit 2f59744d authored by Clayton Coleman's avatar Clayton Coleman

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)
parent e81663c8
...@@ -116,6 +116,10 @@ func (c *Converter) DefaultMeta(t reflect.Type) (FieldMatchingFlags, *Meta) { ...@@ -116,6 +116,10 @@ func (c *Converter) DefaultMeta(t reflect.Type) (FieldMatchingFlags, *Meta) {
// Convert_Slice_byte_To_Slice_byte prevents recursing into every byte // 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 { 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)) *out = make([]byte, len(*in))
copy(*out, *in) copy(*out, *in)
return nil return nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment