aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwmin0 <wmin0@cobinhood.com>2019-04-08 16:55:48 +0800
committerJhih-Ming Huang <jm.huang@cobinhood.com>2019-05-06 10:44:04 +0800
commit34df61db58fcf9c9eb02d20fc9d2f05249c47418 (patch)
tree6e61a27ff5a6a95629905fe6510bfa241d919796
parent400f81ab9892fd7669c54967c7a64470ae5ae7d5 (diff)
downloaddexon-34df61db58fcf9c9eb02d20fc9d2f05249c47418.tar
dexon-34df61db58fcf9c9eb02d20fc9d2f05249c47418.tar.gz
dexon-34df61db58fcf9c9eb02d20fc9d2f05249c47418.tar.bz2
dexon-34df61db58fcf9c9eb02d20fc9d2f05249c47418.tar.lz
dexon-34df61db58fcf9c9eb02d20fc9d2f05249c47418.tar.xz
dexon-34df61db58fcf9c9eb02d20fc9d2f05249c47418.tar.zst
dexon-34df61db58fcf9c9eb02d20fc9d2f05249c47418.zip
core: vm: sqlvm: ast: copy data before decimal decode
Because decimalDecode modifies input data, we should make a copy first to prevent side effect.
-rw-r--r--core/vm/sqlvm/ast/types.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/vm/sqlvm/ast/types.go b/core/vm/sqlvm/ast/types.go
index 7d29a5c49..9bb48bc65 100644
--- a/core/vm/sqlvm/ast/types.go
+++ b/core/vm/sqlvm/ast/types.go
@@ -337,6 +337,8 @@ func decimalEncode(size int, d decimal.Decimal) []byte {
func decimalDecode(signed bool, bs []byte) decimal.Decimal {
neg := false
if signed && (bs[0]&0x80 != 0) {
+ newbs := make([]byte, 0, len(bs))
+ bs = append(newbs, bs...)
neg = true
for idx := range bs {
bs[idx] = ^bs[idx]