riking / AutoDelete

A Discord bot that automatically deletes all messages in a designated channel on a rolling basis
Apache License 2.0
328 stars 117 forks source link

Null pointer crash in QueueLoadBacklog #9

Closed riking closed 4 years ago

riking commented 4 years ago
func (b *Bot) QueueLoadBacklog(c *ManagedChannel, didFail bool) {
    c.mu.Lock() // <= nil pointer dereference
riking commented 4 years ago

Callers:

channel.go:             c.bot.QueueLoadBacklog(c, true)
channel.go:             b.QueueLoadBacklog(c, /* didFail= */ false)
channel.go:             c.bot.QueueLoadBacklog(c, true)
config.go:      b.QueueLoadBacklog(mCh, false)
queue.go:                               b.QueueLoadBacklog(ch, true)
queue.go:                       b.QueueLoadBacklog(ch /* didFail= */, true) // add extra delay

Eliminate 1 and 3 as the channel is known to be non-nil. 4: known non nil. 5, 6: known non nil.

2 - b.channels can contain nil values. Fix.