/ Check-in [af61a2fc]
Login

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

Overview
Comment:Avoid a sanitizer error (pointer arithmatic overflow) in vdbesort.c.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: af61a2fc45a0fa1277d7453779238b77de4c298a9f60714b7dc62ddca5874f80
User & Date: dan 2019-04-16 11:21:13
Context
2019-04-16
19:49
Version 3.28.0 check-in: 884b4b7e user: drh tags: trunk, release, version-3.28.0
11:21
Avoid a sanitizer error (pointer arithmatic overflow) in vdbesort.c. check-in: af61a2fc user: dan tags: trunk
10:51
Avoid a sanitizer error in test1.c. Have releasetest.tcl/wapptest.tcl create a file called "makecommand.sh" that can be used to rerun a test from the command line. check-in: 4de4480f user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbesort.c.

  1824   1824     }
  1825   1825   
  1826   1826     if( pSorter->list.aMemory ){
  1827   1827       int nMin = pSorter->iMemory + nReq;
  1828   1828   
  1829   1829       if( nMin>pSorter->nMemory ){
  1830   1830         u8 *aNew;
  1831         -      int iListOff = (u8*)pSorter->list.pList - pSorter->list.aMemory;
  1832   1831         sqlite3_int64 nNew = 2 * (sqlite3_int64)pSorter->nMemory;
         1832  +      int iListOff = -1;
         1833  +      if( pSorter->list.pList ){
         1834  +        iListOff = (u8*)pSorter->list.pList - pSorter->list.aMemory;
         1835  +      }
  1833   1836         while( nNew < nMin ) nNew = nNew*2;
  1834   1837         if( nNew > pSorter->mxPmaSize ) nNew = pSorter->mxPmaSize;
  1835   1838         if( nNew < nMin ) nNew = nMin;
  1836         -
  1837   1839         aNew = sqlite3Realloc(pSorter->list.aMemory, nNew);
  1838   1840         if( !aNew ) return SQLITE_NOMEM_BKPT;
  1839         -      pSorter->list.pList = (SorterRecord*)&aNew[iListOff];
         1841  +      if( iListOff>=0 ){
         1842  +        pSorter->list.pList = (SorterRecord*)&aNew[iListOff];
         1843  +      }
  1840   1844         pSorter->list.aMemory = aNew;
  1841   1845         pSorter->nMemory = nNew;
  1842   1846       }
  1843   1847   
  1844   1848       pNew = (SorterRecord*)&pSorter->list.aMemory[pSorter->iMemory];
  1845   1849       pSorter->iMemory += ROUND8(nReq);
  1846   1850       if( pSorter->list.pList ){