SQLite

Check-in [e81ccdcd87]
Login

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

Overview
Comment:Fix a potential NULL-pointer dereference in btreeSwapOutMmap().
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | experimental-mmap
Files: files | file ages | folders
SHA1: e81ccdcd87a1387f7ca08d4d7c899311e2180d32
User & Date: drh 2013-03-22 19:56:27.789
Context
2013-03-22
20:15
Update wal mode tests so that they work with the mmap test permutation. (check-in: f7295872a3 user: dan tags: experimental-mmap)
19:56
Fix a potential NULL-pointer dereference in btreeSwapOutMmap(). (check-in: e81ccdcd87 user: drh tags: experimental-mmap)
19:17
Fix a case where the mapped part of a database file may be written during a backup operation. (check-in: c8d67aefff user: dan tags: experimental-mmap)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/btree.c.
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
static int btreeSwapOutMmap(BtShared *pBt){
  int rc = SQLITE_OK;             /* Return code */
  BtCursor *pCsr;                 /* Used to iterate through all open cursors */

  for(pCsr=pBt->pCursor; pCsr && rc==SQLITE_OK; pCsr=pCsr->pNext){
    if( pCsr->iPage>=0 ){
      MemPage *pPg = pCsr->apPage[0];
      if( pPg->pDbPage->flags & PGHDR_MMAP ){
        MemPage *pNew = 0;
        rc = getAndInitPage(pBt, pPg->pgno, &pNew, 0);
        if( rc==SQLITE_OK && pCsr->iPage==0 ){
          pCsr->info.pCell = pNew->aData + (pCsr->info.pCell - pPg->aData);
        }
        pCsr->apPage[0] = pNew;
        releasePage(pPg);







|







2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
static int btreeSwapOutMmap(BtShared *pBt){
  int rc = SQLITE_OK;             /* Return code */
  BtCursor *pCsr;                 /* Used to iterate through all open cursors */

  for(pCsr=pBt->pCursor; pCsr && rc==SQLITE_OK; pCsr=pCsr->pNext){
    if( pCsr->iPage>=0 ){
      MemPage *pPg = pCsr->apPage[0];
      if( pPg && pPg->pDbPage->flags & PGHDR_MMAP ){
        MemPage *pNew = 0;
        rc = getAndInitPage(pBt, pPg->pgno, &pNew, 0);
        if( rc==SQLITE_OK && pCsr->iPage==0 ){
          pCsr->info.pCell = pNew->aData + (pCsr->info.pCell - pPg->aData);
        }
        pCsr->apPage[0] = pNew;
        releasePage(pPg);