From 33ad56e6d0260e30b60a927e3e5be4efc7bb6b53 Mon Sep 17 00:00:00 2001 From: Matt Bell <mappum@gmail.com> Date: Mon, 3 Nov 2014 23:08:41 -0800 Subject: [PATCH] commands: Safer type coercion when choosing marshaller --- commands/response.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/commands/response.go b/commands/response.go index 8cc724f3d..568b5a3ec 100644 --- a/commands/response.go +++ b/commands/response.go @@ -120,11 +120,12 @@ func (r *response) Marshal() ([]byte, error) { return []byte{}, nil } - enc, ok := r.req.Option(EncShort) - if !ok || enc.(string) == "" { + enc, found := r.req.Option(EncShort) + encStr, ok := enc.(string) + if !found || !ok || encStr == "" { return nil, fmt.Errorf("No encoding type was specified") } - encType := EncodingType(strings.ToLower(enc.(string))) + encType := EncodingType(strings.ToLower(encStr)) marshaller, ok := marshallers[encType] if !ok { -- GitLab