/ Check-in [8651aba1]
Login

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

Overview
Comment:Clear a valgrind error by zeroing the first 4 bytes of the temp-space allocation used by the b-tree module.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:8651aba1865a8f82d21d3345f33fbd239fd9a042
User & Date: dan 2013-10-16 11:39:07
Context
2013-10-16
23:58
Fix a typo in a requirements mark comment. No changes to code. check-in: e5a439cf user: drh tags: trunk
14:32
Merge the latest trunk changes. check-in: 58065468 user: drh tags: sessions
11:39
Clear a valgrind error by zeroing the first 4 bytes of the temp-space allocation used by the b-tree module. check-in: 8651aba1 user: dan tags: trunk
11:31
Fix memory and resource leaks for WinCE and Cygwin, and a compiler warning on windows with SQLITE_THREADSAFE=0. check-in: 9905cea9 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  2048   2048   /*
  2049   2049   ** Make sure pBt->pTmpSpace points to an allocation of 
  2050   2050   ** MX_CELL_SIZE(pBt) bytes.
  2051   2051   */
  2052   2052   static void allocateTempSpace(BtShared *pBt){
  2053   2053     if( !pBt->pTmpSpace ){
  2054   2054       pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
         2055  +
         2056  +    /* One of the uses of pBt->pTmpSpace is to format cells before
         2057  +    ** inserting them into a leaf page (function fillInCell()). If
         2058  +    ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
         2059  +    ** by the various routines that manipulate binary cells. Which
         2060  +    ** can mean that fillInCell() only initializes the first 2 or 3
         2061  +    ** bytes of pTmpSpace, but that the first 4 bytes are copied from
         2062  +    ** it into a database page. This is not actually a problem, but it
         2063  +    ** does cause a valgrind error when the 1 or 2 bytes of unitialized 
         2064  +    ** data is passed to system call write(). So to avoid this error,
         2065  +    ** zero the first 4 bytes of temp space here.  */
         2066  +    if( pBt->pTmpSpace ) memset(pBt->pTmpSpace, 0, 4);
  2055   2067     }
  2056   2068   }
  2057   2069   
  2058   2070   /*
  2059   2071   ** Free the pBt->pTmpSpace allocation
  2060   2072   */
  2061   2073   static void freeTempSpace(BtShared *pBt){