aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2022-12-26 15:14:24 +0000
committerdrh <>2022-12-26 15:14:24 +0000
commitff78b2bee8a20485e4efd9571e3a60a92760e4a4 (patch)
tree7fdddf48ce2c4cff45b807dafd9b94bf8c44a97e /src
parent64fa85bb5e5e7870ed1f268c5b915f61e5ea1b28 (diff)
downloadsqlite-ff78b2bee8a20485e4efd9571e3a60a92760e4a4.tar.gz
sqlite-ff78b2bee8a20485e4efd9571e3a60a92760e4a4.zip
Fix an infinite loop in the MEMSYS5 auxiliary memory allocator that occurs
for memory allocations between 1GiB and 2GiB in size. Error introduced by check-in [949133231f8f751a]. The problem only affects builds that include the SQLITE_ENABLE_MEMSYS5 compile-time option. FossilOrigin-Name: 8da0f0c38a458c57f979d59b49cf4804ef81fc2eccabde1f166bab24dd1dabea
Diffstat (limited to 'src')
-rw-r--r--src/mem5.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/mem5.c b/src/mem5.c
index b61b93e11..336f893c6 100644
--- a/src/mem5.c
+++ b/src/mem5.c
@@ -424,9 +424,13 @@ static int memsys5Roundup(int n){
if( n<=mem5.szAtom ) return mem5.szAtom;
return mem5.szAtom*2;
}
- if( n>0x40000000 ) return 0;
+ if( n>0x10000000 ){
+ if( n>0x40000000 ) return 0;
+ if( n>0x20000000 ) return 0x40000000;
+ return 0x2000000;
+ }
for(iFullSz=mem5.szAtom*8; iFullSz<n; iFullSz *= 4);
- if( (iFullSz/2)>=n ) return iFullSz/2;
+ if( (iFullSz/2)>=(i64)n ) return iFullSz/2;
return iFullSz;
}