diff options
author | numist <numist@noemail.net> | 2019-12-12 20:39:47 +0000 |
---|---|---|
committer | numist <numist@noemail.net> | 2019-12-12 20:39:47 +0000 |
commit | c947d6a4dcdfe6f0185a22464cf97153cabb8052 (patch) | |
tree | af10ae8ae82bc15a25775de4369d3bbe25eb126a /src/malloc.c | |
parent | 41cee66848afe40aba1e4d4a83bd50b6c33aaff0 (diff) | |
download | sqlite-c947d6a4dcdfe6f0185a22464cf97153cabb8052.tar.gz sqlite-c947d6a4dcdfe6f0185a22464cf97153cabb8052.zip |
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
Diffstat (limited to 'src/malloc.c')
-rw-r--r-- | src/malloc.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/malloc.c b/src/malloc.c index 8f77c9643..79cdcbcb2 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -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; |