From 2e232f1d63f188e33901a92312e71ec4053e45ce Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Thu, 7 May 2020 13:57:17 +0900 Subject: [PATCH] Append NUL character to end of buffer --- json.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json.go b/json.go index 1511c48..e8f497e 100644 --- a/json.go +++ b/json.go @@ -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)