1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

Make sure the database connection mutex is held before calling

sqlite3SafetyOn() or sqlite3SafetyOff().  Ticket #3059. (CVS 5016)

FossilOrigin-Name: d35dea059e2cb936e4277f513f036b9b0bdfc4a5
This commit is contained in:
drh
2008-04-16 00:49:12 +00:00
parent b08c2a72ea
commit a0af99f91c
4 changed files with 13 additions and 11 deletions

View File

@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.221 2008/04/14 14:34:44 drh Exp $
** $Id: util.c,v 1.222 2008/04/16 00:49:12 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@@ -683,6 +683,7 @@ void *sqlite3HexToBlob(sqlite3 *db, const char *z, int n){
int sqlite3SafetyOn(sqlite3 *db){
if( db->magic==SQLITE_MAGIC_OPEN ){
db->magic = SQLITE_MAGIC_BUSY;
assert( sqlite3_mutex_held(db->mutex) );
return 0;
}else if( db->magic==SQLITE_MAGIC_BUSY ){
db->magic = SQLITE_MAGIC_ERROR;
@@ -701,6 +702,7 @@ int sqlite3SafetyOn(sqlite3 *db){
int sqlite3SafetyOff(sqlite3 *db){
if( db->magic==SQLITE_MAGIC_BUSY ){
db->magic = SQLITE_MAGIC_OPEN;
assert( sqlite3_mutex_held(db->mutex) );
return 0;
}else{
db->magic = SQLITE_MAGIC_ERROR;