Browse Source

fix a crash when SAMODE'ing in a channel you're not joined to

tags/v0.12.0
Shivaram Lingamneni 5 years ago
parent
commit
a18283e2de
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      irc/channel.go

+ 5
- 2
irc/channel.go View File

239
 // ClientIsAtLeast returns whether the client has at least the given channel privilege.
239
 // ClientIsAtLeast returns whether the client has at least the given channel privilege.
240
 func (channel *Channel) ClientIsAtLeast(client *Client, permission modes.Mode) bool {
240
 func (channel *Channel) ClientIsAtLeast(client *Client, permission modes.Mode) bool {
241
 	channel.stateMutex.RLock()
241
 	channel.stateMutex.RLock()
242
-	defer channel.stateMutex.RUnlock()
243
-
244
 	clientModes := channel.members[client]
242
 	clientModes := channel.members[client]
243
+	channel.stateMutex.RUnlock()
244
+
245
+	if clientModes == nil {
246
+		return false
247
+	}
245
 
248
 
246
 	for _, mode := range modes.ChannelUserModes {
249
 	for _, mode := range modes.ChannelUserModes {
247
 		if clientModes.HasMode(mode) {
250
 		if clientModes.HasMode(mode) {

Loading…
Cancel
Save