Skip to content

Commit

Permalink
fix nil buf check
Browse files Browse the repository at this point in the history
Signed-off-by: Vasiliy Tolstov <[email protected]>
  • Loading branch information
vtolstov committed Apr 12, 2021
1 parent b7f6b22 commit af19b4f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion json.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (c *jsonCodec) Marshal(b interface{}) ([]byte, error) {
}

func (c *jsonCodec) Unmarshal(b []byte, v interface{}) error {
if b == nil {
if len(b) == 0 {
return nil
}
switch m := v.(type) {
Expand All @@ -49,6 +49,8 @@ func (c *jsonCodec) ReadBody(conn io.Reader, b interface{}) error {
buf, err := ioutil.ReadAll(conn)
if err != nil {
return err
} else if len(buf) == 0 {
return nil
}
m.Data = buf
return nil
Expand Down

0 comments on commit af19b4f

Please sign in to comment.