diff options
author | dan <dan@noemail.net> | 2014-10-15 19:37:13 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2014-10-15 19:37:13 +0000 |
commit | f11b256b0bad2e843f4df0205bd7093f632aa38d (patch) | |
tree | be608b0913db6a27e576bd58c4e07e73abf73de7 /src/btree.c | |
parent | 92fe38ece56c01929b8ad949c94a8b7732db496c (diff) | |
parent | 5d510d4c412ec360cec5cd088fd8debff94e3354 (diff) | |
download | sqlite-f11b256b0bad2e843f4df0205bd7093f632aa38d.tar.gz sqlite-f11b256b0bad2e843f4df0205bd7093f632aa38d.zip |
Merge latest trunk changes with this branch.
FossilOrigin-Name: 1b2824f1d11ac336779372e322aecfb36fb2a31d
Diffstat (limited to 'src/btree.c')
-rw-r--r-- | src/btree.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/btree.c b/src/btree.c index 3553924c0..758dfe633 100644 --- a/src/btree.c +++ b/src/btree.c @@ -2108,7 +2108,8 @@ static int removeFromSharingList(BtShared *pBt){ /* ** Make sure pBt->pTmpSpace points to an allocation of -** MX_CELL_SIZE(pBt) bytes. +** MX_CELL_SIZE(pBt) bytes with a 4-byte prefix for a left-child +** pointer. */ static void allocateTempSpace(BtShared *pBt){ if( !pBt->pTmpSpace ){ @@ -2123,8 +2124,16 @@ static void allocateTempSpace(BtShared *pBt){ ** it into a database page. This is not actually a problem, but it ** does cause a valgrind error when the 1 or 2 bytes of unitialized ** data is passed to system call write(). So to avoid this error, - ** zero the first 4 bytes of temp space here. */ - if( pBt->pTmpSpace ) memset(pBt->pTmpSpace, 0, 4); + ** zero the first 4 bytes of temp space here. + ** + ** Also: Provide four bytes of initialized space before the + ** beginning of pTmpSpace as an area available to prepend the + ** left-child pointer to the beginning of a cell. + */ + if( pBt->pTmpSpace ){ + memset(pBt->pTmpSpace, 0, 8); + pBt->pTmpSpace += 4; + } } } @@ -2132,8 +2141,11 @@ static void allocateTempSpace(BtShared *pBt){ ** Free the pBt->pTmpSpace allocation */ static void freeTempSpace(BtShared *pBt){ - sqlite3PageFree( pBt->pTmpSpace); - pBt->pTmpSpace = 0; + if( pBt->pTmpSpace ){ + pBt->pTmpSpace -= 4; + sqlite3PageFree(pBt->pTmpSpace); + pBt->pTmpSpace = 0; + } } /* |