Ensure that the pcache1 cache size does not get so big that it overflows

the integer that is keeping track of the cache size.

FossilOrigin-Name: bf9d70fc2fde06a3f132270a26d4abe321687169066aff26ad9e92757c7f9ee4
This commit is contained in:
drh
2021-08-09 18:07:06 +00:00
parent 9d16fb1c09
commit 8a72882425
3 changed files with 11 additions and 8 deletions
+4 -1
View File
@@ -820,6 +820,9 @@ static void pcache1Cachesize(sqlite3_pcache *p, int nMax){
if( pCache->bPurgeable ){
PGroup *pGroup = pCache->pGroup;
pcache1EnterMutex(pGroup);
if( nMax > 0xffff0000 - pGroup->nMaxPage + pCache->nMax ){
nMax = 0xffff0000 - pGroup->nMaxPage + pCache->nMax;
}
pGroup->nMaxPage += (nMax - pCache->nMax);
pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
pCache->nMax = nMax;
@@ -838,7 +841,7 @@ static void pcache1Shrink(sqlite3_pcache *p){
PCache1 *pCache = (PCache1*)p;
if( pCache->bPurgeable ){
PGroup *pGroup = pCache->pGroup;
int savedMaxPage;
unsigned int savedMaxPage;
pcache1EnterMutex(pGroup);
savedMaxPage = pGroup->nMaxPage;
pGroup->nMaxPage = 0;