diff options
author | drh <drh@noemail.net> | 2018-10-29 18:33:42 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-10-29 18:33:42 +0000 |
commit | 5aa20378f7edae2e3c51cda3f7a87609555fc15d (patch) | |
tree | c3b40492bbe6199527ac3cc53905a5f7c03d3022 /src | |
parent | dbe7d37ae8e69a1e5252dca2c83badb471ff1310 (diff) | |
download | sqlite-5aa20378f7edae2e3c51cda3f7a87609555fc15d.tar.gz sqlite-5aa20378f7edae2e3c51cda3f7a87609555fc15d.zip |
Fix minor memory leak in the dbstat extension that can occur following an
attempt to analyze a corrupt database file.
FossilOrigin-Name: cb874fd87384be397008e953242d5773ef5d64e07c3e1ae352a42a25d70597b4
Diffstat (limited to 'src')
-rw-r--r-- | src/dbstat.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/dbstat.c b/src/dbstat.c index 0eb70d6ce..ca0d54101 100644 --- a/src/dbstat.c +++ b/src/dbstat.c @@ -254,7 +254,7 @@ static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){ return SQLITE_OK; } -static void statClearPage(StatPage *p){ +static void statClearCells(StatPage *p){ int i; if( p->aCell ){ for(i=0; i<p->nCell; i++){ @@ -262,6 +262,12 @@ static void statClearPage(StatPage *p){ } sqlite3_free(p->aCell); } + p->nCell = 0; + p->aCell = 0; +} + +static void statClearPage(StatPage *p){ + statClearCells(p); sqlite3PagerUnref(p->pPg); sqlite3_free(p->zPath); memset(p, 0, sizeof(StatPage)); @@ -417,7 +423,7 @@ static int statDecodePage(Btree *pBt, StatPage *p){ statPageIsCorrupt: p->flags = 0; - p->nCell = 0; + statClearCells(p); return SQLITE_OK; } |