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 }