upstream: fix panic in isChannel

Fixes the following:

    goroutine 4380762 [running]:
    runtime/debug.Stack()
    	runtime/debug/stack.go:24 +0x65
    git.sr.ht/~emersion/soju.(*Server)addUserLocked.func1.1()
    	git.sr.ht/~emersion/soju/server.go:318 +0x66
    panic({0x563f090c4460, 0xc002bff998})
    	runtime/panic.go:1038 +0x215
    git.sr.ht/~emersion/soju.(*upstreamConn).isChannel(...)
    	git.sr.ht/~emersion/soju/upstream.go:288
    git.sr.ht/~emersion/soju.(*downstreamConn).handleMessageRegistered(0xc00c23a000, {0x563f0910eb20, 0xc0027539e0}, 0xc01b8d6240)
    	git.sr.ht/~emersion/soju/downstream.go:1836 +0xd4ec
    git.s.ht/~emersion/soju.(*downstreamConn).handleMessage(0xc00c3a000, {0x563f0910eae8, 0xc000026058}, 0xc01b8d6240)
    	git.sr.ht/~emersion/soju/downstream.go:697 +0xde
    git.sr.ht/~emersion/soju.(*user).run(0xc00be4a0b0)
    	git.sr.ht/~emersion/soju/user.go:675 +0xbe5
    git.sr.ht/~emersion/soju.(*Server).addUserLocked.func1()
    	git.sr.ht/~emersion/soju/server.go:328 +0x70
This commit is contained in:
Simon Ser 2022-05-07 09:28:53 +02:00
parent 9d188a7cb6
commit 27f21eab94

View File

@ -290,7 +290,7 @@ func (uc *upstreamConn) getChannel(name string) (*upstreamChannel, error) {
} }
func (uc *upstreamConn) isChannel(entity string) bool { func (uc *upstreamConn) isChannel(entity string) bool {
return strings.ContainsRune(uc.availableChannelTypes, rune(entity[0])) return len(entity) > 0 && strings.ContainsRune(uc.availableChannelTypes, rune(entity[0]))
} }
func (uc *upstreamConn) isOurNick(nick string) bool { func (uc *upstreamConn) isOurNick(nick string) bool {