Append NUL character to end of buffer

This commit is contained in:
Masaaki Goshima 2020-05-07 13:57:17 +09:00
parent ceed634708
commit 2e232f1d63
1 changed files with 2 additions and 2 deletions

View File

@ -166,14 +166,14 @@ func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
}
func Unmarshal(data []byte, v interface{}) error {
src := make([]byte, len(data))
src := make([]byte, len(data)+1) // append nul byte to end
copy(src, data)
var dec Decoder
return dec.decodeForUnmarshal(src, v)
}
func UnmarshalNoEscape(data []byte, v interface{}) error {
src := make([]byte, len(data))
src := make([]byte, len(data)+1) // append nul byte to end
copy(src, data)
var dec Decoder
return dec.decodeForUnmarshalNoEscape(src, v)