Skip to content

panic in Reader.more() when underlying reader returns an error #25

@kamstrup

Description

@kamstrup

Thanks for a great library!

One of my tests at work passes a buggy reader into our stack and asserts that we catch the error correctly. I ran into a crash in Reader.more()

goroutine 13 [running]:
testing.tRunner.func1.2({0xf4b320, 0xc00003aa80})
	/usr/local/go1.18.3/src/testing/testing.go:1389 +0x477
testing.tRunner.func1()
	/usr/local/go1.18.3/src/testing/testing.go:1392 +0x610
panic({0xf4b320, 0xc00003aa80})
	/usr/local/go1.18.3/src/runtime/panic.go:844 +0x25a
github.com/philhofer/fwd.(*Reader).more(0xc000033a90)
	/home/kamstrup/go/pkg/mod/github.com/philhofer/fwd@v1.1.1/reader.go:133 +0x493
github.com/philhofer/fwd.(*Reader).Peek(0xc000033a90, 0x1)
	/home/kamstrup/go/pkg/mod/github.com/philhofer/fwd@v1.1.1/reader.go:182 +0x2b5
github.com/tinylib/msgp/msgp.(*Reader).ReadArrayHeader(0xc0002fd1c0)
	/home/kamstrup/go/pkg/mod/github.com/tinylib/msgp@v1.1.6/msgp/read.go:452 +0x87
... SNIP

if r.r.Read() errors a=-1 and if r.data is mpty on line 133 then we access r.data[-1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions