nickvanw / ircx

Basic callback-driven Go IRC bot
Apache License 2.0
37 stars 13 forks source link

Possible access a member of nil #25

Closed Mr-KoKa closed 5 years ago

Mr-KoKa commented 8 years ago

I've noticed something, ReadLoop does this:

        msg, err := b.reader.Decode()
        if err != nil {
            return b.Reconnect()
        }
        b.Data <- msg

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.

nickvanw commented 5 years ago

Closed in #29