Skip to content

Commit

Permalink
fix resp package BulkString funtion
Browse files Browse the repository at this point in the history
  • Loading branch information
YIDWang committed Jan 20, 2019
1 parent cc4c698 commit 367a45f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions encoding/resp/resp.go
Expand Up @@ -227,7 +227,7 @@ func (r *Decoder) BulkString() (string, error) {
}

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

Expand Down Expand Up @@ -256,7 +256,7 @@ func (r *Decoder) Array() (int, error) {
return -1, ErrInvalidProtocol
}
remain, err := strconv.Atoi(string(hdr[1 : l-2]))
if err != nil {
if err != nil || remain < 0 {
return -1, ErrInvalidProtocol
}
return remain, nil
Expand Down

0 comments on commit 367a45f

Please sign in to comment.