1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Fix an issue where malloc could be used to fulfill a small allocation when a large lookaside slot could have beeen used instead.

FossilOrigin-Name: 611020e3378f4c81c277cccd84807ae51a816bbab6c3d887c91c5e5af3b5225f
This commit is contained in:
numist
2019-12-12 20:39:47 +00:00
parent 41cee66848
commit c947d6a4dc
3 changed files with 13 additions and 10 deletions

View File

@@ -582,8 +582,10 @@ void *sqlite3DbMallocRawNN(sqlite3 *db, u64 n){
return db->mallocFailed ? 0 : dbMallocRawFinish(db, n);
}
db->lookaside.anStat[1]++;
return dbMallocRawFinish(db, n);
}
# ifndef SQLITE_OMIT_MINI_LOOKASIDE
}else if( n<=MINI_SZ ){
if( n<=MINI_SZ ){
if( (pBuf = db->lookaside.pMiniFree)!=0 ){
db->lookaside.pMiniFree = pBuf->pNext;
db->lookaside.anStat[0]++;
@@ -593,8 +595,9 @@ void *sqlite3DbMallocRawNN(sqlite3 *db, u64 n){
db->lookaside.anStat[0]++;
return (void*)pBuf;
}
}
# endif
}else if( (pBuf = db->lookaside.pFree)!=0 ){
if( (pBuf = db->lookaside.pFree)!=0 ){
db->lookaside.pFree = pBuf->pNext;
db->lookaside.anStat[0]++;
return (void*)pBuf;