diff options
author | drh <drh@noemail.net> | 2018-01-27 14:25:27 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-01-27 14:25:27 +0000 |
commit | 1822ebf9b1997c4bc8ed3371b065a494bac3d6d5 (patch) | |
tree | f054112943e2bb7e2ec036aa4a050c711d66f33e /src/util.c | |
parent | c9f3db33d5547187f1ce129452d20e2b0b1e86ff (diff) | |
download | sqlite-1822ebf9b1997c4bc8ed3371b065a494bac3d6d5.tar.gz sqlite-1822ebf9b1997c4bc8ed3371b065a494bac3d6d5.zip |
Changes to avoid a harmless UB warning from clang.
FossilOrigin-Name: 19f5c1400054df10688ab448e7e23afef97cab4a7c7a3e411f7527509b515dd8
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c index 9954d709d..54f9b9388 100644 --- a/src/util.c +++ b/src/util.c @@ -641,7 +641,13 @@ int sqlite3Atoi64(const char *zNum, i64 *pNum, int length, u8 enc){ testcase( i==18*incr ); testcase( i==19*incr ); testcase( i==20*incr ); - if( neg ){ + if( u>LARGEST_INT64 ){ + /* This test and assignment is needed only to suppress UB warnings + ** from clang and -fsanitize=undefined. This test and assignment make + ** the code a little larger and slower, and no harm comes from omitting + ** them, but we must appaise the undefined-behavior pharisees. */ + *pNum = neg ? SMALLEST_INT64 : LARGEST_INT64; + }else if( neg ){ *pNum = -(i64)u; }else{ *pNum = (i64)u; |