fix nil buf check
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
		| @@ -39,7 +39,7 @@ func (c *jsonpbCodec) Marshal(v interface{}) ([]byte, error) { | ||||
| } | ||||
|  | ||||
| func (c *jsonpbCodec) Unmarshal(d []byte, v interface{}) error { | ||||
| 	if d == nil { | ||||
| 	if len(d) == 0 { | ||||
| 		return nil | ||||
| 	} | ||||
| 	switch m := v.(type) { | ||||
| @@ -65,6 +65,8 @@ func (c *jsonpbCodec) 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 | ||||
| @@ -72,7 +74,7 @@ func (c *jsonpbCodec) ReadBody(conn io.Reader, b interface{}) error { | ||||
| 		buf, err := ioutil.ReadAll(conn) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} else if buf == nil { | ||||
| 		} else if len(buf) == 0 { | ||||
| 			return nil | ||||
| 		} | ||||
| 		return JsonpbUnmarshaler.Unmarshal(buf, m) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user