From: drh Date: Thu, 7 Apr 2016 18:42:23 +0000 (+0000) Subject: Prevent the in-memory journal read cursor from entering an inconsistent state X-Git-Tag: version-3.13.0~118 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=38b3dde00e766eb3e121b947c5c2c527d329503c;p=thirdparty%2Fsqlite.git Prevent the in-memory journal read cursor from entering an inconsistent state when it reads the last few bytes out of the journal file. Fix for ticket [7f7f8026eda38]. FossilOrigin-Name: c4b9c611bdcd85f31d68aaf114ee34a9f27eba6d --- diff --git a/manifest b/manifest index 54bbc7ace8..56e23c1277 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sdecrementing\sa\spointer\soff\sthe\sfront\send\sof\sthe\sbuffer\sin\sOP_MakeRecord. -D 2016-04-07T14:16:16.723 +C Prevent\sthe\sin-memory\sjournal\sread\scursor\sfrom\sentering\san\sinconsistent\sstate\nwhen\sit\sreads\sthe\slast\sfew\sbytes\sout\sof\sthe\sjournal\sfile.\s\sFix\sfor\nticket\s[7f7f8026eda38]. +D 2016-04-07T18:42:23.186 F Makefile.in eba680121821b8a60940a81454316f47a341487a F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 1f123a0757f6f04f0341accb46457e116817159a @@ -347,7 +347,7 @@ F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944 -F src/memjournal.c 5253fd4335a8d9c64e5df25cb9da6329af5242c7 +F src/memjournal.c 2815ef7684671d93a1ec6a31e1e63c45de4b4d31 F src/msvc.h d9ba56c6851227ab44b3f228a35f3f5772296495 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85 @@ -1482,7 +1482,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 8415d4848ab36ca33b23d1fad6b063544de04a3b -R 03453ebf1870335c86f4514ee1d5c7ac +P 153135bfb3b8f7c407ccf36571e2d4d5afe28ea3 +R 79f1b101d10963168c95e54e3a571e58 U drh -Z 0a2d3c19f1c3d2a6467caf636e91907c +Z fee1386714e022b25f3a73738d6ccce7 diff --git a/manifest.uuid b/manifest.uuid index b3cd228a8b..c077c241b6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -153135bfb3b8f7c407ccf36571e2d4d5afe28ea3 \ No newline at end of file +c4b9c611bdcd85f31d68aaf114ee34a9f27eba6d \ No newline at end of file diff --git a/src/memjournal.c b/src/memjournal.c index 4f0efc174e..fbfa7cb802 100644 --- a/src/memjournal.c +++ b/src/memjournal.c @@ -94,6 +94,7 @@ static int memjrnlRead( #endif assert( (iAmt+iOfst)<=p->endpoint.iOffset ); + assert( p->readpoint.iOffset==0 || p->readpoint.pChunk!=0 ); if( p->readpoint.iOffset!=iOfst || iOfst==0 ){ sqlite3_int64 iOff = 0; for(pChunk=p->pFirst; @@ -104,6 +105,7 @@ static int memjrnlRead( } }else{ pChunk = p->readpoint.pChunk; + assert( pChunk!=0 ); } iChunkOffset = (int)(iOfst%p->nChunkSize); @@ -115,7 +117,7 @@ static int memjrnlRead( nRead -= iSpace; iChunkOffset = 0; } while( nRead>=0 && (pChunk=pChunk->pNext)!=0 && nRead>0 ); - p->readpoint.iOffset = iOfst+iAmt; + p->readpoint.iOffset = pChunk ? iOfst+iAmt : 0; p->readpoint.pChunk = pChunk; return SQLITE_OK;