1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Fix a bug in a test file causing malloc5.test to crash. (CVS 4331)

FossilOrigin-Name: ab09967bd2dd291030850d44c0862fbb7d0d8118
This commit is contained in:
danielk1977
2007-08-30 08:27:39 +00:00
parent 65839c6afd
commit f3c626594e
3 changed files with 21 additions and 8 deletions

View File

@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test3.c,v 1.84 2007/08/29 17:43:20 drh Exp $
** $Id: test3.c,v 1.85 2007/08/30 08:27:40 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "btreeInt.h"
@@ -557,6 +557,16 @@ static int btree_pager_stats(
return TCL_ERROR;
}
pBt = sqlite3TextToPtr(argv[1]);
/* Normally in this file, with a b-tree handle opened using the
** [btree_open] command it is safe to call sqlite3BtreeEnter() directly.
** But this function is sometimes called with a btree handle obtained
** from an open SQLite connection (using [btree_from_db]). In this case
** we need to obtain the mutex for the controlling SQLite handle before
** it is safe to call sqlite3BtreeEnter().
*/
sqlite3_mutex_enter(pBt->pSqlite->mutex);
sqlite3BtreeEnter(pBt);
a = sqlite3PagerStats(sqlite3BtreePager(pBt));
for(i=0; i<11; i++){
@@ -570,6 +580,9 @@ static int btree_pager_stats(
Tcl_AppendElement(interp, zBuf);
}
sqlite3BtreeLeave(pBt);
/* Release the mutex on the SQLite handle that controls this b-tree */
sqlite3_mutex_leave(pBt->pSqlite->mutex);
return TCL_OK;
}