From 96528cbae4311106c361914f20e548a00fdbdc87 Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Mon, 16 Nov 2020 23:39:33 +0900 Subject: [PATCH] Fix resolve conflict to #55 --- encode_vm.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/encode_vm.go b/encode_vm.go index 21ef38c..d71e032 100644 --- a/encode_vm.go +++ b/encode_vm.go @@ -187,8 +187,8 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error { code = code.next case opBytesIndent: ptr := load(ctxptr, code.idx) - header := (*reflect.SliceHeader)(unsafe.Pointer(ptr)) - if ptr == 0 || header.Data == 0 { + header := (*sliceHeader)(unsafe.Pointer(&ptr)) + if ptr == 0 || uintptr(header.data) == 0 { e.encodeNull() } else { e.encodeByteSlice(e.ptrToBytes(ptr)) @@ -205,7 +205,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error { } v := *(*interface{})(unsafe.Pointer(&interfaceHeader{ typ: code.typ, - ptr: unsafe.Pointer(ptr), + ptr: *(*unsafe.Pointer)(unsafe.Pointer(&ptr)), })) if _, exists := seenPtr[ptr]; exists { return &UnsupportedValueError{ @@ -407,7 +407,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error { ptr := load(ctxptr, code.idx) v := *(*interface{})(unsafe.Pointer(&interfaceHeader{ typ: code.typ, - ptr: unsafe.Pointer(ptr), + ptr: *(*unsafe.Pointer)(unsafe.Pointer(&ptr)), })) b, err := v.(Marshaler).MarshalJSON() if err != nil { @@ -472,7 +472,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error { case opMarshalTextIndent: ptr := load(ctxptr, code.idx) isPtr := code.typ.Kind() == reflect.Ptr - p := unsafe.Pointer(ptr) + p := *(*unsafe.Pointer)(unsafe.Pointer(&ptr)) if p == nil { e.encodeNull() e.encodeBytes([]byte{',', '\n'})