1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

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
This commit is contained in:
drh
2016-04-07 18:42:23 +00:00
parent 45c3c66385
commit 38b3dde00e
3 changed files with 10 additions and 8 deletions

View File

@@ -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;