Fix panic when String is called on nil mode pointers. Fixes #98.

This commit is contained in:
Alex Bramley 2018-09-06 22:23:59 +01:00
parent 47162eb0b8
commit 08c1bcf174
2 changed files with 9 additions and 0 deletions

View File

@ -299,6 +299,9 @@ func (ch *channel) String() string {
// Returns a string representing the channel modes. Looks like: // Returns a string representing the channel modes. Looks like:
// +npk key // +npk key
func (cm *ChanMode) String() string { func (cm *ChanMode) String() string {
if cm == nil {
return "No modes set"
}
str := "+" str := "+"
a := make([]string, 0) a := make([]string, 0)
v := reflect.Indirect(reflect.ValueOf(cm)) v := reflect.Indirect(reflect.ValueOf(cm))
@ -335,6 +338,9 @@ func (cm *ChanMode) String() string {
// Returns a string representing the channel privileges. Looks like: // Returns a string representing the channel privileges. Looks like:
// +o // +o
func (cp *ChanPrivs) String() string { func (cp *ChanPrivs) String() string {
if cp == nil {
return "No modes set"
}
str := "+" str := "+"
v := reflect.Indirect(reflect.ValueOf(cp)) v := reflect.Indirect(reflect.ValueOf(cp))
t := v.Type() t := v.Type()

View File

@ -183,6 +183,9 @@ func (nk *nick) String() string {
// Returns a string representing the nick modes. Looks like: // Returns a string representing the nick modes. Looks like:
// +iwx // +iwx
func (nm *NickMode) String() string { func (nm *NickMode) String() string {
if nm == nil {
return "No modes set"
}
str := "+" str := "+"
v := reflect.Indirect(reflect.ValueOf(nm)) v := reflect.Indirect(reflect.ValueOf(nm))
t := v.Type() t := v.Type()