fix UnmarshalMsg return value. Returns the origanal data if the error occurs.

This commit is contained in:
13981712066 2021-12-06 09:29:46 +08:00
parent 5f79fa610c
commit c7eaaded9c

View file

@ -39,12 +39,12 @@ func (d *Decimal) UnmarshalMsg(b []byte) ([]byte, error) {
l := len(b) l := len(b)
if l < 1 { if l < 1 {
return nil, errShortBytes return o, err
} }
sz := int(b[0] & 0x1f) sz := int(b[0] & 0x1f)
if len(b[1:]) < sz { if len(b[1:]) < sz {
return nil, errShortBytes return o, err
} }
if *d, err = NewFromString(string(b[1 : sz+1])); err == nil { if *d, err = NewFromString(string(b[1 : sz+1])); err == nil {
o = b[sz:] o = b[sz:]