ohler55 / ojg

Optimized JSON for Go
MIT License
857 stars 49 forks source link

panic: assignment to entry in nil map #38

Closed walkerxiong closed 3 years ago

walkerxiong commented 3 years ago

(*Parser).Parse function called will crash when the first parameter buf is "{\"\"\"\":0", the error trace is as follows

panic: assignment to entry in nil map

goroutine 1 [running]:
github.com/ohler55/ojg/oj.(*Parser).add(0xc000096cf0, 0x10d5ca0, 0x1192120)
    /workspace/ojg/oj/parser.go:558 +0x107
github.com/ohler55/ojg/oj.(*Parser).parseBuffer(0xc000096cf0, 0xc000096cd0, 0x7, 0x20, 0x1, 0x1114140, 0x20)
    /workspace/ojg/oj/parser.go:538 +0x4d0a
github.com/ohler55/ojg/oj.(*Parser).Parse(0xc000096cf0, 0xc000096cd0, 0x7, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1114140, ...)
    /workspace/ojg/oj/parser.go:87 +0x4a5
github.com/ohler55/ojg/oj.ParseString(0xc000096e78, 0x7, 0x0, 0x0, 0x0, 0x1fa79b70, 0x1fa79b7000000000, 0x60370d9b, 0xc000096e98)
    /workspace/ojg/oj/oj.go:27 +0xee
github.com/ohler55/ojg.Fuzz(0xa321000, 0x7, 0x7, 0x3)
    /workspace/ojg/fuzz.go:6 +0x87
go-fuzz-dep.Main(0xc000096f70, 0x1, 0x1)
    go-fuzz-dep/main.go:36 +0x1b8
main.main()
    github.com/ohler55/ojg/go.fuzz.main/main.go:15 +0x52
exit status 2
ohler55 commented 3 years ago

I'll get it fixed tonight.

ohler55 commented 3 years ago

Fixed in v1.7.1. It was important enough to release quickly. Please try and if it fixes the issue you can close this issue.

walkerxiong commented 3 years ago

I haven't found this bug anymore,thanks