mikespook/gearman-go

panic: runtime error: slice bounds out of range

Closed this issue · 0 comments

panic: runtime error: slice bounds out of range

goroutine 5 [running]:
github.com/mikespook/gearman-go/worker.decodeInPack(0xc2000fe000, 0x400, 0x400, 0x0, 0x0, ...)
        /opt/go/src/github.com/mikespook/gearman-go/worker/inpack.go:97 +0xa6f
github.com/mikespook/gearman-go/worker.(*agent).work(0xc200081410)
        /opt/go/src/github.com/mikespook/gearman-go/worker/agent.go:75 +0x324
created by github.com/mikespook/gearman-go/worker.(*agent).Connect
        /opt/go/src/github.com/mikespook/gearman-go/worker/agent.go:41 +0x192

This happens because decodeInPack tries to decode the packet as soon as the amount of bytes received is > 12, but often the data received is only 1024 and the packet size may be bigger.

I have submitted a pull request with a fix.