Index: third_party/sqlite/amalgamation/sqlite3.c |
diff --git a/third_party/sqlite/amalgamation/sqlite3.c b/third_party/sqlite/amalgamation/sqlite3.c |
index 22e11146c99db9946935e7e44a4bb5f3dd9a546e..54d0260bb25bf307c0803e7dcfbaf38c1fc3aa8d 100644 |
--- a/third_party/sqlite/amalgamation/sqlite3.c |
+++ b/third_party/sqlite/amalgamation/sqlite3.c |
@@ -137639,6 +137639,7 @@ struct RecoverLeafCursor { |
*/ |
static int leafCursorLoadPage(RecoverLeafCursor *pCursor, DbPage *pPage){ |
const unsigned char *pPageHeader; /* Header of *pPage */ |
+ unsigned nCells; /* Number of cells in the page */ |
/* Release the current page. */ |
if( pCursor->pPage ){ |
@@ -137668,10 +137669,17 @@ static int leafCursorLoadPage(RecoverLeafCursor *pCursor, DbPage *pPage){ |
return SQLITE_OK; |
} |
+ /* Leaf contains no data, skip it. Empty tables, for instance. */ |
+ nCells = decodeUnsigned16(pPageHeader + kiPageCellCountOffset);; |
+ if( nCells<1 ){ |
+ sqlite3PagerUnref(pPage); |
+ return SQLITE_OK; |
+ } |
+ |
/* Take ownership of the page and start decoding. */ |
pCursor->pPage = pPage; |
pCursor->iCell = 0; |
- pCursor->nCells = decodeUnsigned16(pPageHeader + kiPageCellCountOffset); |
+ pCursor->nCells = nCells; |
return SQLITE_OK; |
} |