/ Check-in [2d71cbdf]
Login

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

Overview
Comment:Avoid a potential (harmless) signed integer overflow in memory usage accounting when calling sqlite3_realloc() to reduce the size of an allocation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2d71cbdf6bc24f0269027c70b39ea7f342436bdb
User & Date: drh 2016-12-27 12:08:36
Context
2016-12-27
12:35
Disable new test modules nockpt.test and interrupt2.test for incompatible permutations. Add a CORRUPT_DB term to an assert() in vdbe.c. check-in: a54e619e user: drh tags: trunk
12:08
Avoid a potential (harmless) signed integer overflow in memory usage accounting when calling sqlite3_realloc() to reduce the size of an allocation. check-in: 2d71cbdf user: drh tags: trunk
02:43
Minor changes to make some newer test cases work under more compile-time options. check-in: 382eea36 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/malloc.c.

   515    515     nNew = sqlite3GlobalConfig.m.xRoundup((int)nBytes);
   516    516     if( nOld==nNew ){
   517    517       pNew = pOld;
   518    518     }else if( sqlite3GlobalConfig.bMemstat ){
   519    519       sqlite3_mutex_enter(mem0.mutex);
   520    520       sqlite3StatusHighwater(SQLITE_STATUS_MALLOC_SIZE, (int)nBytes);
   521    521       nDiff = nNew - nOld;
   522         -    if( sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= 
          522  +    if( nDiff>0 && sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED) >= 
   523    523             mem0.alarmThreshold-nDiff ){
   524    524         sqlite3MallocAlarm(nDiff);
   525    525       }
   526    526       pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
   527    527       if( pNew==0 && mem0.alarmThreshold>0 ){
   528    528         sqlite3MallocAlarm((int)nBytes);
   529    529         pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);