Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic in decoder #374

Closed
eatonphil opened this issue Jun 25, 2022 · 2 comments · Fixed by #380
Closed

Panic in decoder #374

eatonphil opened this issue Jun 25, 2022 · 2 comments · Fixed by #380

Comments

@eatonphil
Copy link

Not even sure how to start reproducing this unfortunately.

panic: runtime error: index out of range [403] with length 403

goroutine 52 [running]:
github.com/goccy/go-json/internal/decoder.(*Stream).char(...)
        github.com/goccy/go-json@v0.9.7/internal/decoder/stream.go:79
github.com/goccy/go-json/internal/decoder.(*interfaceDecoder).decodeStreamEmptyInterface(0xc00014a190, 0xc255d00d20, 0x56310e273245?, 0xc0017ae2d0)
        github.com/goccy/go-json@v0.9.7/internal/decoder/interface.go:236 +0x67b
github.com/goccy/go-json/internal/decoder.(*interfaceDecoder).DecodeStream(0xc00014a190, 0xc255d00d20, 0xc000088e30?, 0xc0017ae2d0)
        github.com/goccy/go-json@v0.9.7/internal/decoder/interface.go:318 +0x5c5
github.com/goccy/go-json/internal/decoder.(*mapDecoder).DecodeStream(0xc0000a0c60, 0xc255d00d20, 0x0?, 0xc001749aa8)
        github.com/goccy/go-json@v0.9.7/internal/decoder/map.go:107 +0x3aa
github.com/goccy/go-json.(*Decoder).DecodeWithOption(0xc001749aa0, {0x56310ff7c960, 0xc001749aa8}, {0x0, 0x0, 0x0?})
        github.com/goccy/go-json@v0.9.7/decode.go:202 +0xf4
github.com/goccy/go-json.(*Decoder).Decode(...)
        github.com/goccy/go-json@v0.9.7/decode.go:168
github.com/multiprocessio/datastation/runner.loadJSONArrayFile.func1()
        github.com/multiprocessio/datastation/runner@v0.0.0-20220616090857-d42388371862/json.go:121 +0x13d
created by github.com/multiprocessio/datastation/runner.loadJSONArrayFile
        github.com/multiprocessio/datastation/runner@v0.0.0-20220616090857-d42388371862/json.go:109 +0x12e
@james-d-elliott
Copy link

It'd probably be useful for the maintainer if you had some example to reproduce this.

@orisano
Copy link
Sponsor Contributor

orisano commented Jul 5, 2022

func TestIssue374(t *testing.T) {
	r := io.MultiReader(strings.NewReader(strings.Repeat(" ", 505)+`"\u`), strings.NewReader(`0000"`))
	var v interface{}
	json.NewDecoder(r).Decode(&v)
}

I reproduced the panic in the same place, though it may not be the same cause.

orisano added a commit to orisano/go-json that referenced this issue Jul 6, 2022
orisano added a commit to orisano/go-json that referenced this issue Jul 6, 2022
orisano added a commit to orisano/go-json that referenced this issue Jul 6, 2022
orisano added a commit to orisano/go-json that referenced this issue Jul 7, 2022
@goccy goccy closed this as completed in #380 Jul 9, 2022
goccy added a commit that referenced this issue Jul 9, 2022
Fix unicode decoding when the expected buffer state is not met after reading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants