mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Fix a potential use-after-free following an OOM in sqlite3ParserAddCleanup()
and add a mechanism to detect situations where this might occur in the future. FossilOrigin-Name: 38ef8ab9830e12acd2c710e113939b1f8dced02612c6933c37a3c948a4030d0a
This commit is contained in:
@@ -370,8 +370,9 @@ static int autoIncBegin(
|
||||
while( pInfo && pInfo->pTab!=pTab ){ pInfo = pInfo->pNext; }
|
||||
if( pInfo==0 ){
|
||||
pInfo = sqlite3DbMallocRawNN(pParse->db, sizeof(*pInfo));
|
||||
if( pInfo==0 ) return 0;
|
||||
sqlite3ParserAddCleanup(pToplevel, sqlite3DbFreeNN, pInfo);
|
||||
sqlite3ParserAddCleanup(pToplevel, sqlite3DbFree, pInfo);
|
||||
testcase( pParse->earlyCleanup );
|
||||
if( pParse->db->mallocFailed ) return 0;
|
||||
pInfo->pNext = pToplevel->pAinc;
|
||||
pToplevel->pAinc = pInfo;
|
||||
pInfo->pTab = pTab;
|
||||
|
||||
Reference in New Issue
Block a user