mirror of https://github.com/goccy/go-json.git
Keep unsafe.Pointer reference for handling of opInterface
This commit is contained in:
parent
6a11c84d0c
commit
35395bba60
|
@ -216,6 +216,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error {
|
|||
}
|
||||
seenPtr[ptr] = struct{}{}
|
||||
v := e.ptrToInterface(code, ptr)
|
||||
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(&v))
|
||||
rv := reflect.ValueOf(v)
|
||||
if rv.IsNil() {
|
||||
e.encodeNull()
|
||||
|
@ -292,6 +293,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error {
|
|||
}
|
||||
seenPtr[ptr] = struct{}{}
|
||||
v := e.ptrToInterface(code, ptr)
|
||||
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(&v))
|
||||
rv := reflect.ValueOf(v)
|
||||
if rv.IsNil() {
|
||||
e.encodeNull()
|
||||
|
|
Loading…
Reference in New Issue