Fix encoding of nil value for opMarshalText

This commit is contained in:
Masaaki Goshima 2020-12-23 01:42:49 +09:00
parent 24aa07e47f
commit 7e55f41a59
1 changed files with 1 additions and 4 deletions

View File

@ -486,10 +486,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
ptr := load(ctxptr, code.idx)
isPtr := code.typ.Kind() == reflect.Ptr
p := e.ptrToUnsafePtr(ptr)
if p == nil {
b = encodeNull(b)
b = encodeComma(b)
} else if isPtr && *(*unsafe.Pointer)(p) == nil {
if p == nil || isPtr && *(*unsafe.Pointer)(p) == nil {
b = append(b, '"', '"', ',')
} else {
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{