forked from mirror/go-json
Merge pull request #60 from goccy/feature/fix-unexpected-free-pointer
Fix a bugs where pointers are unexpectedly freed
This commit is contained in:
commit
5ab988208f
|
@ -19,7 +19,12 @@ jobs:
|
|||
uses: actions/checkout@v2
|
||||
|
||||
- name: Test
|
||||
run: go test -v ./
|
||||
run: go test -v ./ -count=1
|
||||
|
||||
- name: Test with race detector
|
||||
run: go test -v -race ./
|
||||
- name: Test with GC
|
||||
run: go test -v ./ -count=1
|
||||
env:
|
||||
GOGC: 1
|
||||
|
||||
# - name: Test with race detector
|
||||
# run: go test -v -race ./ -count=1
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -225,9 +225,6 @@ var (
|
|||
)
|
||||
|
||||
func initBig() {
|
||||
if len(jsonBig) > 0 {
|
||||
return
|
||||
}
|
||||
n := 10000
|
||||
if testing.Short() {
|
||||
n = 100
|
||||
|
|
Loading…
Reference in New Issue