aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authordrh <>2023-06-30 11:51:36 +0000
committerdrh <>2023-06-30 11:51:36 +0000
commit60f41362cfa65da5baa992367156f67d738e1be3 (patch)
tree04c36b70ac2f3fbaf19618f22654bb582426c6a5 /src/util.c
parent2ddfa6a360ede3e370201b9f45737f8a350be198 (diff)
downloadsqlite-60f41362cfa65da5baa992367156f67d738e1be3.tar.gz
sqlite-60f41362cfa65da5baa992367156f67d738e1be3.zip
Make the sum() function less precise and slower in order to avoid
harmless signed integer overflow UBSAN warnings from OSS-Fuzz. FossilOrigin-Name: 1be0646a2c352dbf03d2af87fd48b6f9edfd68666790ac6863144ac95f3e0621
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/util.c b/src/util.c
index 256ec7c5c..ab8560839 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1761,8 +1761,14 @@ int sqlite3VListNameToNum(VList *pIn, const char *zName, int nName){
/* Compute z = (i64)x */
void sqlite3DDFromInt(i64 x, double *z){
- z[0] = (double)x;
- z[1] = (double)(x - (i64)z[0]);
+ if( x > -4503599627370496L && x < 4503599627370496 ){
+ z[0] = (double)x;
+ z[1] = 0.0;
+ }else{
+ i64 y = x % 2048;
+ z[0] = (double)(x - y);
+ z[1] = (double)(x - (i64)z[0]);
+ }
}
/* Compute z = x + y */