@cryptotaxi247 / kubo / commits / c2f46b618

commands: Fixed panic on nil output value

Matt Bell committed Jan 6, 2015 at 11:54 UTC c2f46b618a0121e2814a3506c2f8160aca893238
1 file changed +8 -5
commands/command.go
+8 -5
@@ -114,13 +114,16 @@ func (c *Command) Call(req Request) Response {
114 return res
115 }
116
117 + isChan := false
118 actualType := reflect.TypeOf(output)
118 - if actualType.Kind() == reflect.Ptr {
119 - actualType = actualType.Elem()
120 - }
119 + if actualType != nil {
120 + if actualType.Kind() == reflect.Ptr {
121 + actualType = actualType.Elem()
122 + }
123
122 - // test if output is a channel
123 - isChan := actualType.Kind() == reflect.Chan
124 + // test if output is a channel
125 + isChan = actualType.Kind() == reflect.Chan
126 + }
127
128 // If the command specified an output type, ensure the actual value returned is of that type
129 if cmd.Type != nil && !isChan {