From 1dee7474000c6eab8d454d51aa6a16b9651b61e4 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Wed, 23 Dec 2020 01:29:13 +0900 Subject: [PATCH] Assign nil at null value --- decode_ptr.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/decode_ptr.go b/decode_ptr.go index a62a691..2b507bf 100644 --- a/decode_ptr.go +++ b/decode_ptr.go @@ -40,6 +40,7 @@ func (d *ptrDecoder) decodeStream(s *stream, p unsafe.Pointer) error { if err := nullBytes(s); err != nil { return err } + *(*unsafe.Pointer)(p) = nil return nil } newptr := unsafe_New(d.typ) @@ -66,6 +67,7 @@ func (d *ptrDecoder) decode(buf []byte, cursor int64, p unsafe.Pointer) (int64, if buf[cursor+3] != 'l' { return 0, errInvalidCharacter(buf[cursor+3], "null", cursor) } + *(*unsafe.Pointer)(p) = nil cursor += 4 return cursor, nil }