From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Stanislav Zudin Subject: [PATCH 12/13] sql: fixes an error in uint64 to double casting Date: Fri, 15 Mar 2019 18:45:41 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: To: tarantool-patches@freelists.org, vdavydov.dev@gmail.com Cc: Stanislav Zudin List-ID: --- src/box/sql/util.c | 2 +- src/box/sql/vdbeInt.h | 2 ++ src/box/sql/vdbemem.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/box/sql/util.c b/src/box/sql/util.c index 17268aaaa..d585dc0d5 100644 --- a/src/box/sql/util.c +++ b/src/box/sql/util.c @@ -1318,7 +1318,7 @@ sqlAddInt64(i64 * pA, bool is_signedA, i64 iB, bool is_signedB) if (sum == INT64_MIN_MOD) { *pA = INT64_MIN; } else { - assert(sum < INT64_MAX); + assert(sum <= INT64_MAX); *pA = -(i64)sum; } return ATHR_SIGNED; diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index 42f22df52..2076a9a14 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -251,6 +251,8 @@ struct Mem { #define MEM_Unsigned 0x20000 /* Value is unsigned integer. * Combine this flag with MEM_Int * if necessary */ +#define MEM_UInt (MEM_Int | MEM_Unsigned) + #ifdef SQL_OMIT_INCRBLOB #undef MEM_Zero #define MEM_Zero 0x0000 diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c index 2805d7a01..9e6d52b47 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -489,7 +489,7 @@ sqlVdbeRealValue(Mem * pMem, double *v) if (pMem->flags & MEM_Real) { *v = pMem->u.r; return 0; - } else if (pMem->flags & (MEM_Int | MEM_Unsigned)) { + } else if ((pMem->flags & MEM_UInt) == MEM_UInt) { *v = (double)(u64)pMem->u.i; return 0; } else if (pMem->flags & MEM_Int) { -- 2.17.1