And Decode function uses ParseMessage() function which can return nil, and if that occurs then msg is nil and it is sent to b.Data and then used in HandleLoop
for msg := range b.Data {
b.onMessage(msg)
}
And it will panic inside onMessage, because there is no nil check so it will try to access .Command
handlers, ok := b.handlers[m.Command]
I made check inside HandleLoop so onMessage is called only when msg is not nil.
I do check inside onMessage if m is not nil.
I've noticed something, ReadLoop does this:
And Decode function uses ParseMessage() function which can return nil, and if that occurs then msg is nil and it is sent to b.Data and then used in HandleLoop
And it will panic inside onMessage, because there is no nil check so it will try to access .Command
handlers, ok := b.handlers[m.Command]
I made check inside HandleLoop so onMessage is called only when msg is not nil.I do check inside onMessage if m is not nil.