Skip to content

Commit

Permalink
fix return -1
Browse files Browse the repository at this point in the history
  • Loading branch information
YIDWang committed Jan 21, 2019
1 parent 367a45f commit 995df90
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions encoding/resp/resp.go
Expand Up @@ -226,6 +226,11 @@ func (r *Decoder) BulkString() (string, error) {
return "", ErrInvalidProtocol
}

if hdr[0] == '-' && len(hdr) == 2 && hdr[1] == '1' {
// handle $-1 and $-1 null replies.
return "", nil
}

remain, err := strconv.Atoi(string(hdr[1 : l-2]))
if err != nil || remain < 0 {
return "", ErrInvalidProtocol
Expand Down

0 comments on commit 995df90

Please sign in to comment.