1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-10-21 11:13:54 +03:00

Make the sum() function less precise and slower in order to avoid

harmless signed integer overflow UBSAN warnings from OSS-Fuzz.

FossilOrigin-Name: 1be0646a2c352dbf03d2af87fd48b6f9edfd68666790ac6863144ac95f3e0621
This commit is contained in:
drh
2023-06-30 11:51:36 +00:00
parent 2ddfa6a360
commit 60f41362cf
5 changed files with 26 additions and 15 deletions

View File

@@ -1740,8 +1740,13 @@ static void sumFinalize(sqlite3_context *context){
if( p->approx ){
sqlite3_result_double(context, p->rSum[0]+p->rSum[1]);
}else{
i64 v = (i64)p->rSum[0] + (i64)p->rSum[1];
double r = p->rSum[0] + p->rSum[1];
i64 v;
double y[2], z[2];
v = sqlite3RealToI64(p->rSum[0]);
if( sqlite3AddInt64(&v, sqlite3RealToI64(p->rSum[1])) ){
v = 0;
}
sqlite3DDFromInt(v, y);
sqlite3DDSub(y[0], y[1], p->rSum[0], p->rSum[1], z);
if( z[0] + z[1] != 0.0 ){