/ Check-in [6c2d34df]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Harden sqlite3session_delete() against trying to delete a session that is not currently on the session list.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sessions
Files: files | file ages | folders
SHA1: 6c2d34df76fb7823f307c11a1135ab30674421a9
User & Date: drh 2016-02-13 14:45:56
Context
2016-02-13
15:08
Fix another test problem in sessionfault.test. check-in: f6d1cf79 user: dan tags: sessions
14:45
Harden sqlite3session_delete() against trying to delete a session that is not currently on the session list. check-in: 6c2d34df user: drh tags: sessions
14:39
Fix a problem in sessionfault.test causing it to segfault following a test failure. This commit does not fix the actual test failure - just the subsequent segfault. check-in: 582b2ae7 user: dan tags: sessions
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/session/sqlite3session.c.

  1611   1611     sqlite3_session *pHead;
  1612   1612     sqlite3_session **pp;
  1613   1613   
  1614   1614     /* Unlink the session from the linked list of sessions attached to the
  1615   1615     ** database handle. Hold the db mutex while doing so.  */
  1616   1616     sqlite3_mutex_enter(sqlite3_db_mutex(db));
  1617   1617     pHead = (sqlite3_session*)sqlite3_preupdate_hook(db, 0, 0);
  1618         -  for(pp=&pHead; (*pp)!=pSession; pp=&((*pp)->pNext));
  1619         -  *pp = (*pp)->pNext;
  1620         -  if( pHead ) sqlite3_preupdate_hook(db, xPreUpdate, (void *)pHead);
         1618  +  for(pp=&pHead; ALWAYS((*pp)!=0); pp=&((*pp)->pNext)){
         1619  +    if( (*pp)==pSession ){
         1620  +      *pp = (*pp)->pNext;
         1621  +      if( pHead ) sqlite3_preupdate_hook(db, xPreUpdate, (void*)pHead);
         1622  +      break;
         1623  +    }
         1624  +  }
  1621   1625     sqlite3_mutex_leave(sqlite3_db_mutex(db));
  1622   1626   
  1623   1627     /* Delete all attached table objects. And the contents of their 
  1624   1628     ** associated hash-tables. */
  1625   1629     sessionDeleteTable(pSession->pTable);
  1626   1630   
  1627   1631     /* Free the session object itself. */