forked from mirror/go-json
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{}{}
|
seenPtr[ptr] = struct{}{}
|
||||||
v := e.ptrToInterface(code, ptr)
|
v := e.ptrToInterface(code, ptr)
|
||||||
|
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(&v))
|
||||||
rv := reflect.ValueOf(v)
|
rv := reflect.ValueOf(v)
|
||||||
if rv.IsNil() {
|
if rv.IsNil() {
|
||||||
e.encodeNull()
|
e.encodeNull()
|
||||||
|
@ -292,6 +293,7 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, code *opcode) error {
|
||||||
}
|
}
|
||||||
seenPtr[ptr] = struct{}{}
|
seenPtr[ptr] = struct{}{}
|
||||||
v := e.ptrToInterface(code, ptr)
|
v := e.ptrToInterface(code, ptr)
|
||||||
|
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(&v))
|
||||||
rv := reflect.ValueOf(v)
|
rv := reflect.ValueOf(v)
|
||||||
if rv.IsNil() {
|
if rv.IsNil() {
|
||||||
e.encodeNull()
|
e.encodeNull()
|
||||||
|
|
Loading…
Reference in New Issue