aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test_vfs.c8
-rw-r--r--src/wal.c21
2 files changed, 20 insertions, 9 deletions
diff --git a/src/test_vfs.c b/src/test_vfs.c
index 1212a51e7..d14f93c54 100644
--- a/src/test_vfs.c
+++ b/src/test_vfs.c
@@ -341,6 +341,7 @@ static void tvfsGrowBuffer(TestvfsShm *pShm, int reqSize, int *pNewSize){
TestvfsBuffer *pBuffer = pShm->pBuffer;
if( reqSize>pBuffer->n ){
pBuffer->a = (u8 *)ckrealloc((char *)pBuffer->a, reqSize);
+ memset(&pBuffer->a[pBuffer->n], 0x55, reqSize-pBuffer->n);
pBuffer->n = reqSize;
}
*pNewSize = pBuffer->n;
@@ -467,11 +468,13 @@ static int tvfsShmSize(
Testvfs *p = (Testvfs *)(pVfs->pAppData);
TestvfsShm *pShm = (TestvfsShm *)pShmHandle;
- tvfsGrowBuffer(pShm, reqSize, pNewSize);
tvfsExecTcl(p, "xShmSize",
Tcl_NewStringObj(pShm->pBuffer->zFile, -1), pShm->id, 0
);
tvfsResultCode(p, &rc);
+ if( rc==SQLITE_OK ){
+ tvfsGrowBuffer(pShm, reqSize, pNewSize);
+ }
return rc;
}
@@ -549,7 +552,9 @@ static int tvfsShmClose(
TestvfsShm *pShm = (TestvfsShm *)pShmHandle;
TestvfsBuffer *pBuffer = pShm->pBuffer;
+#if 0
assert( (deleteFlag!=0)==(pBuffer->nRef==1) );
+#endif
tvfsExecTcl(p, "xShmClose",
Tcl_NewStringObj(pShm->pBuffer->zFile, -1), pShm->id, 0
@@ -759,6 +764,7 @@ static int testvfs_cmd(
pVfs->zName = p->zName;
pVfs->mxPathname = p->pParent->mxPathname;
pVfs->szOsFile += p->pParent->szOsFile;
+ p->pVfs = pVfs;
Tcl_CreateObjCommand(interp, zVfs, testvfs_obj_cmd, p, testvfs_obj_del);
sqlite3_vfs_register(pVfs, 0);
diff --git a/src/wal.c b/src/wal.c
index 5a6e41fd5..0a3657c3b 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -670,7 +670,7 @@ static int walIteratorNext(
return (iRet==0xFFFFFFFF);
}
-static WalIterator *walIteratorInit(Wal *pWal){
+static int walIteratorInit(Wal *pWal, WalIterator **pp){
u32 *aData; /* Content of the wal-index file */
WalIterator *p; /* Return value */
int nSegment; /* Number of segments to merge */
@@ -680,8 +680,12 @@ static WalIterator *walIteratorInit(Wal *pWal){
int nFinal; /* Number of unindexed entries */
struct WalSegment *pFinal; /* Final (unindexed) segment */
u8 *aTmp; /* Temp space used by merge-sort */
+ int rc; /* Return code of walIndexMap() */
- walIndexMap(pWal, -1);
+ rc = walIndexMap(pWal, -1);
+ if( rc!=SQLITE_OK ){
+ return rc;
+ }
aData = pWal->pWiData;
iLast = pWal->hdr.iLastPg;
nSegment = (iLast >> 8) + 1;
@@ -689,6 +693,9 @@ static WalIterator *walIteratorInit(Wal *pWal){
nByte = sizeof(WalIterator) + (nSegment-1)*sizeof(struct WalSegment) + 512;
p = (WalIterator *)sqlite3_malloc(nByte);
+ if( !p ){
+ return SQLITE_NOMEM;
+ }
if( p ){
memset(p, 0, nByte);
@@ -710,7 +717,8 @@ static WalIterator *walIteratorInit(Wal *pWal){
p->nFinal = nFinal;
}
- return p;
+ *pp = p;
+ return SQLITE_OK;
}
/*
@@ -737,11 +745,8 @@ static int walCheckpoint(
u32 iFrame = 0; /* Wal frame containing data for iDbpage */
/* Allocate the iterator */
- pIter = walIteratorInit(pWal);
- if( !pIter ) return SQLITE_NOMEM;
-
- if( pWal->hdr.iLastPg==0 ){
- rc = SQLITE_OK;
+ rc = walIteratorInit(pWal, &pIter);
+ if( rc!=SQLITE_OK || pWal->hdr.iLastPg==0 ){
goto out;
}