Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: third_party/sqlite/src/src/recover.c

Issue 1671773003: [sqlite] Fix bug in how recover virtual table handles empty. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/amalgamation/sqlite3.c ('k') | third_party/sqlite/src/test/recover.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/src/recover.c
diff --git a/third_party/sqlite/src/src/recover.c b/third_party/sqlite/src/src/recover.c
index 8e3929d453be4db35ebe8468185e54905485f667..58dd89e1f2f6f9011b028137acccd5a27e7525b8 100644
--- a/third_party/sqlite/src/src/recover.c
+++ b/third_party/sqlite/src/src/recover.c
@@ -1138,6 +1138,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 ){
@@ -1167,10 +1168,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 ){
Ryan Hamilton 2016/02/05 17:51:25 The style... it burns my eyes!
Scott Hess - ex-Googler 2016/02/05 18:18:05 Yeah! It's essentially opposite Google/Chromium s
+ 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;
}
Ryan Hamilton 2016/02/05 17:51:25 This diff appears to be basically the same as the
Scott Hess - ex-Googler 2016/02/05 18:18:05 Oh, sorry, should have mentioned that, too. In th
« no previous file with comments | « third_party/sqlite/amalgamation/sqlite3.c ('k') | third_party/sqlite/src/test/recover.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698