From 3fcf0b4e0934e8d9009f6ef0d239525ca4681e88 Mon Sep 17 00:00:00 2001 From: liwei Date: Thu, 21 Jul 2022 18:23:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcodec=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E9=94=99=E8=AF=AF=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/codec/utils/float.go | 2 ++ lego/sys/codec/utils/int.go | 8 ++++++-- modules/shop/model_shop.go | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lego/sys/codec/utils/float.go b/lego/sys/codec/utils/float.go index 58c1a2b8d..012184cdd 100644 --- a/lego/sys/codec/utils/float.go +++ b/lego/sys/codec/utils/float.go @@ -52,6 +52,7 @@ func ReadBigFloatForString(buf []byte) (ret *big.Float, n int, err error) { func ReadFloat32ForString(buf []byte) (ret float32, n int, err error) { if buf[0] == '-' { ret, n, err = readPositiveFloat32(buf[1:]) + n++ ret = -ret return } @@ -60,6 +61,7 @@ func ReadFloat32ForString(buf []byte) (ret float32, n int, err error) { func ReadFloat64ForString(buf []byte) (ret float64, n int, err error) { if buf[0] == '-' { ret, n, err = readPositiveFloat64(buf[1:]) + n++ ret = -ret return } diff --git a/lego/sys/codec/utils/int.go b/lego/sys/codec/utils/int.go index 8eb08960b..01a27bc44 100644 --- a/lego/sys/codec/utils/int.go +++ b/lego/sys/codec/utils/int.go @@ -41,6 +41,7 @@ func ReadInt8ForString(buf []byte) (ret int8, n int, err error) { c := buf[0] if c == '-' { val, n, err = ReadUint32ForString(buf[1:]) + n++ if val > math.MaxInt8+1 { err = errors.New("ReadInt8ForString overflow: " + strconv.FormatInt(int64(val), 10)) return @@ -64,6 +65,7 @@ func ReadInt16ForString(buf []byte) (ret int16, n int, err error) { c := buf[0] if c == '-' { val, n, err = ReadUint32ForString(buf[1:]) + n++ if val > math.MaxInt16+1 { err = errors.New("ReadInt16ForString overflow: " + strconv.FormatInt(int64(val), 10)) return @@ -87,6 +89,7 @@ func ReadInt32ForString(buf []byte) (ret int32, n int, err error) { c := buf[0] if c == '-' { val, n, err = ReadUint32ForString(buf[1:]) + n++ if val > math.MaxInt32+1 { err = errors.New("ReadInt32ForString overflow: " + strconv.FormatInt(int64(val), 10)) return @@ -110,6 +113,7 @@ func ReadInt64ForString(buf []byte) (ret int64, n int, err error) { c := buf[0] if c == '-' { val, n, err = ReadUint64ForString(buf[1:]) + n++ if val > math.MaxInt64+1 { err = errors.New("ReadInt64ForString overflow: " + strconv.FormatInt(int64(val), 10)) return @@ -154,6 +158,7 @@ func ReadUint16ForString(buf []byte) (ret uint16, n int, err error) { func ReadUint32ForString(buf []byte) (ret uint32, n int, err error) { ind := intDigits[buf[0]] + n = 1 if ind == 0 { err = assertInteger(buf[1:]) return @@ -163,7 +168,6 @@ func ReadUint32ForString(buf []byte) (ret uint32, n int, err error) { return } ret = uint32(ind) - n = 1 if len(buf) > 10 { i := 1 ind2 := intDigits[buf[i]] @@ -252,6 +256,7 @@ func ReadUint32ForString(buf []byte) (ret uint32, n int, err error) { func ReadUint64ForString(buf []byte) (ret uint64, n int, err error) { ind := intDigits[buf[0]] + n = 1 if ind == 0 { err = assertInteger(buf[1:]) return @@ -261,7 +266,6 @@ func ReadUint64ForString(buf []byte) (ret uint64, n int, err error) { return } ret = uint64(ind) - n = 1 if len(buf) > 10 { i := 0 ind2 := intDigits[buf[i]] diff --git a/modules/shop/model_shop.go b/modules/shop/model_shop.go index 1194f53a8..97eb4b8af 100644 --- a/modules/shop/model_shop.go +++ b/modules/shop/model_shop.go @@ -30,6 +30,8 @@ func (this *modelShopComp) Init(service core.IService, module core.IModule, comp //查询用户装备数据 func (this *modelShopComp) QueryUserShopData(uId string) (data *pb.DBShop, err error) { data = &pb.DBShop{} - err = this.Get(uId, data) + if err = this.Get(uId, data); err != nil { + this.module.Errorf("err:%v", err) + } return }