From 09cf9b200748e9ebbc0ea7172a34bcfcfb78267b Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 12 Apr 2021 19:19:08 +0300 Subject: [PATCH] fix nil buf check Signed-off-by: Vasiliy Tolstov --- xml.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xml.go b/xml.go index 1676b9d..02249c0 100644 --- a/xml.go +++ b/xml.go @@ -23,7 +23,7 @@ func (c *xmlCodec) Marshal(b interface{}) ([]byte, error) { } func (c *xmlCodec) Unmarshal(b []byte, v interface{}) error { - if b == nil { + if len(b) == 0 { return nil } switch m := v.(type) { @@ -49,6 +49,8 @@ func (c *xmlCodec) 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