commands: Fixed panic when marshalers gave nil output
Matt Bell committed
Jan 6, 2015 at 12:25 UTC
2816ed038c88aad09362c2b3d17521f56fcfb57e
1 file changed
+8
-1
commands/response.go
+8
-1
@@ -160,7 +160,14 @@ func (r *response) Marshal() (io.Reader, error) {
160
}
161
}
162
163
- return marshaller(r)
163
+ output, err := marshaller(r)
164
+ if err != nil {
165
+ return nil, err
166
+ }
167
+ if output == nil {
168
+ return bytes.NewReader([]byte{}), nil
169
+ }
170
+ return output, nil
171
}
172
173
// Reader returns an `io.Reader` representing marshalled output of this Response