mirror of https://github.com/goccy/go-json.git
Fix initialize seenPtr
This commit is contained in:
parent
d85327b458
commit
7083274627
11
encode_vm.go
11
encode_vm.go
|
@ -51,7 +51,7 @@ func errMarshaler(code *opcode, err error) *MarshalerError {
|
||||||
|
|
||||||
func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte, error) {
|
func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte, error) {
|
||||||
recursiveLevel := 0
|
recursiveLevel := 0
|
||||||
seenPtr := map[uintptr]struct{}{}
|
var seenPtr map[uintptr]struct{}
|
||||||
ptrOffset := uintptr(0)
|
ptrOffset := uintptr(0)
|
||||||
ctxptr := ctx.ptr()
|
ctxptr := ctx.ptr()
|
||||||
|
|
||||||
|
@ -211,6 +211,9 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
||||||
code = code.next
|
code = code.next
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if seenPtr == nil {
|
||||||
|
seenPtr = map[uintptr]struct{}{}
|
||||||
|
}
|
||||||
if _, exists := seenPtr[ptr]; exists {
|
if _, exists := seenPtr[ptr]; exists {
|
||||||
return nil, errUnsupportedValue(code, ptr)
|
return nil, errUnsupportedValue(code, ptr)
|
||||||
}
|
}
|
||||||
|
@ -288,6 +291,9 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
||||||
code = code.next
|
code = code.next
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if seenPtr == nil {
|
||||||
|
seenPtr = map[uintptr]struct{}{}
|
||||||
|
}
|
||||||
if _, exists := seenPtr[ptr]; exists {
|
if _, exists := seenPtr[ptr]; exists {
|
||||||
return nil, errUnsupportedValue(code, ptr)
|
return nil, errUnsupportedValue(code, ptr)
|
||||||
}
|
}
|
||||||
|
@ -992,6 +998,9 @@ func (e *Encoder) run(ctx *encodeRuntimeContext, b []byte, code *opcode) ([]byte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if seenPtr == nil {
|
||||||
|
seenPtr = map[uintptr]struct{}{}
|
||||||
|
}
|
||||||
seenPtr[ptr] = struct{}{}
|
seenPtr[ptr] = struct{}{}
|
||||||
c := code.jmp.code
|
c := code.jmp.code
|
||||||
c.end.next = newEndOp(&encodeCompileContext{})
|
c.end.next = newEndOp(&encodeCompileContext{})
|
||||||
|
|
Loading…
Reference in New Issue