aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanielk1977 <danielk1977@noemail.net>2009-02-17 16:29:10 +0000
committerdanielk1977 <danielk1977@noemail.net>2009-02-17 16:29:10 +0000
commit0a5490715925605759dfa60991f974bcc184d1be (patch)
tree2e83a83699893b8494c0f21f6a6ae532899c8558 /src
parente8df800d4cb57917b4d909678cb467a200120e96 (diff)
downloadsqlite-0a5490715925605759dfa60991f974bcc184d1be.tar.gz
sqlite-0a5490715925605759dfa60991f974bcc184d1be.zip
Allow sqlite3_shutdown() to be called by a process before sqlite3_initialize() is. Prior to this commit such a call could segfault. (CVS 6296)
FossilOrigin-Name: 79431c58d964d6057c7f42f7c1df74f3df4493eb
Diffstat (limited to 'src')
-rw-r--r--src/malloc.c6
-rw-r--r--src/mutex.c6
-rw-r--r--src/tclsqlite.c8
3 files changed, 15 insertions, 5 deletions
diff --git a/src/malloc.c b/src/malloc.c
index a92fae06b..d9c036da6 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -12,7 +12,7 @@
**
** Memory allocation functions used throughout sqlite.
**
-** $Id: malloc.c,v 1.54 2009/01/20 16:53:41 danielk1977 Exp $
+** $Id: malloc.c,v 1.55 2009/02/17 16:29:11 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
@@ -153,7 +153,9 @@ int sqlite3MallocInit(void){
** Deinitialize the memory allocation subsystem.
*/
void sqlite3MallocEnd(void){
- sqlite3GlobalConfig.m.xShutdown(sqlite3GlobalConfig.m.pAppData);
+ if( sqlite3GlobalConfig.m.xShutdown ){
+ sqlite3GlobalConfig.m.xShutdown(sqlite3GlobalConfig.m.pAppData);
+ }
memset(&mem0, 0, sizeof(mem0));
}
diff --git a/src/mutex.c b/src/mutex.c
index 03cae57bf..d7b769d73 100644
--- a/src/mutex.c
+++ b/src/mutex.c
@@ -14,7 +14,7 @@
** This file contains code that is common across all mutex implementations.
**
-** $Id: mutex.c,v 1.29 2008/10/07 15:25:48 drh Exp $
+** $Id: mutex.c,v 1.30 2009/02/17 16:29:11 danielk1977 Exp $
*/
#include "sqliteInt.h"
@@ -67,7 +67,9 @@ int sqlite3MutexInit(void){
*/
int sqlite3MutexEnd(void){
int rc = SQLITE_OK;
- rc = sqlite3GlobalConfig.mutex.xMutexEnd();
+ if( sqlite3GlobalConfig.mutex.xMutexEnd ){
+ rc = sqlite3GlobalConfig.mutex.xMutexEnd();
+ }
return rc;
}
diff --git a/src/tclsqlite.c b/src/tclsqlite.c
index 4e7f77dd2..585360f56 100644
--- a/src/tclsqlite.c
+++ b/src/tclsqlite.c
@@ -12,7 +12,7 @@
** A TCL Interface to SQLite. Append this file to sqlite3.c and
** compile the whole thing to build a TCL-enabled version of SQLite.
**
-** $Id: tclsqlite.c,v 1.236 2009/02/04 22:46:47 drh Exp $
+** $Id: tclsqlite.c,v 1.237 2009/02/17 16:29:11 danielk1977 Exp $
*/
#include "tcl.h"
#include <errno.h>
@@ -2744,6 +2744,12 @@ static char zMainloop[] =
#define TCLSH_MAIN main /* Needed to fake out mktclapp */
int TCLSH_MAIN(int argc, char **argv){
Tcl_Interp *interp;
+
+ /* Call sqlite3_shutdown() once before doing anything else. This is to
+ ** test that sqlite3_shutdown() can be safely called by a process before
+ ** sqlite3_initialize() is. */
+ sqlite3_shutdown();
+
Tcl_FindExecutable(argv[0]);
interp = Tcl_CreateInterp();
Sqlite3_Init(interp);