1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Harden sqlite3session_delete() against trying to delete a session that

is not currently on the session list.

FossilOrigin-Name: 6c2d34df76fb7823f307c11a1135ab30674421a9
This commit is contained in:
drh
2016-02-13 14:45:56 +00:00
parent 6fee795885
commit 50d348b1e1
3 changed files with 15 additions and 11 deletions

View File

@ -1615,9 +1615,13 @@ void sqlite3session_delete(sqlite3_session *pSession){
** database handle. Hold the db mutex while doing so. */
sqlite3_mutex_enter(sqlite3_db_mutex(db));
pHead = (sqlite3_session*)sqlite3_preupdate_hook(db, 0, 0);
for(pp=&pHead; (*pp)!=pSession; pp=&((*pp)->pNext));
*pp = (*pp)->pNext;
if( pHead ) sqlite3_preupdate_hook(db, xPreUpdate, (void *)pHead);
for(pp=&pHead; ALWAYS((*pp)!=0); pp=&((*pp)->pNext)){
if( (*pp)==pSession ){
*pp = (*pp)->pNext;
if( pHead ) sqlite3_preupdate_hook(db, xPreUpdate, (void*)pHead);
break;
}
}
sqlite3_mutex_leave(sqlite3_db_mutex(db));
/* Delete all attached table objects. And the contents of their