Index: src/wal.c ================================================================== --- src/wal.c +++ src/wal.c @@ -449,19 +449,27 @@ u32 *pnTruncate, /* OUT: New db size (or 0 if not commit) */ u8 *aData, /* Pointer to page data (for checksum) */ u8 *aFrame /* Frame data */ ){ int nativeCksum; /* True for native byte-order checksums */ + u32 pgno; /* Page number of the frame */ u32 aCksum[2]; assert( WAL_FRAME_HDRSIZE==24 ); /* A frame is only valid if the salt values in the frame-header ** match the salt values in the wal-header. */ if( memcmp(&pWal->hdr.aSalt, &aFrame[8], 8)!=0 ){ return 0; } + + /* A frame is only valid if the page number is creater than zero. + */ + pgno = sqlite3Get4byte(&aFrame[0]); + if( pgno==0 ){ + return 0; + } /* A frame is only valid if a checksum of the first 16 bytes ** of the frame-header, and the frame-data matches ** the checksum in the last 8 bytes of the frame-header. */ @@ -476,11 +484,11 @@ } /* If we reach this point, the frame is valid. Return the page number ** and the new database size. */ - *piPage = sqlite3Get4byte(&aFrame[0]); + *piPage = pgno; *pnTruncate = sqlite3Get4byte(&aFrame[4]); return 1; } /*