Browse Source

Better edge case handling

Ben Hood 11 năm trước cách đây
mục cha
commit
712d53a3dc
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      marshal.go

+ 5 - 1
marshal.go

@@ -717,8 +717,12 @@ func unmarshalDecimal(info *TypeInfo, data []byte, value interface{}) error {
 			scale := decInt(data[0:4])
 			unscaled := decBigInt2C(data[4:])
 			*v = inf.NewDecBig(unscaled, inf.Scale(scale))
+			return nil
+		} else if len(data) == 0 {
+			return nil
+		} else {
+			return unmarshalErrorf("can not unmarshal %s into %T", info, value)
 		}
-		return nil
 	}
 	return unmarshalErrorf("can not unmarshal %s into %T", info, value)
 }