Skip to content

Commit

Permalink
fix unmarshaling null into []byte
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Nov 1, 2018
1 parent 10eebc3 commit c6752ca
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions obj/unmarshalBuiltins.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ func (mach *unmarshalMachinePrimitive) Step(_ *Unmarshaller, _ *unmarshalSlab, t
case TBytes:
mach.rv.SetBytes(tok.Bytes)
return true, nil
case TNull:
mach.rv.SetBytes(nil)
return true, nil
default:
return true, ErrUnmarshalTypeCantFit{*tok, mach.rv, 0}
}
Expand All @@ -138,6 +141,12 @@ func (mach *unmarshalMachinePrimitive) Step(_ *Unmarshaller, _ *unmarshalSlab, t
mach.rv.Index(i).SetUint(uint64(tok.Bytes[i]))
}
return true, nil
case TNull:
if mach.rv.Len() != 0 {
return true, ErrUnmarshalTypeCantFit{*tok, mach.rv, 0}
}
mach.rv.SetBytes(nil)
return true, nil
default:
return true, ErrUnmarshalTypeCantFit{*tok, mach.rv, 0}
}
Expand Down

0 comments on commit c6752ca

Please sign in to comment.