Fix an assertion fault in pcache introduced by [4bc93658aa563f2f] and

detected by OSSFuzz.  Test case in TH3.

FossilOrigin-Name: 2262a49467fa56c386080dac3e99a66e16c1700e138dba74db66e7b93ae76bf5
This commit is contained in:
drh
2021-09-03 18:11:12 +00:00
parent 748d8b9cdd
commit e7e9539d99
3 changed files with 12 additions and 9 deletions
+4 -1
View File
@@ -243,11 +243,14 @@ static int numberOfCachePages(PCache *p){
** suggested cache size is set to N. */
return p->szCache;
}else{
i64 n;
/* IMPLEMANTATION-OF: R-59858-46238 If the argument N is negative, then the
** number of cache pages is adjusted to be a number of pages that would
** use approximately abs(N*1024) bytes of memory based on the current
** page size. */
return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
n = ((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
if( n>1000000000 ) n = 1000000000;
return (int)n;
}
}