@@ -111,7 +111,17 @@ int sqlite3MallocInit(void){
111111 int rc ;
112112 if ( sqlite3GlobalConfig .m .xMalloc == 0 ){
113113 sqlite3MemSetDefault ();
114- /* BEGIN SQLCIPHER */
114+
115+ memset (& mem0 , 0 , sizeof (mem0 ));
116+ mem0 .mutex = sqlite3MutexAlloc (SQLITE_MUTEX_STATIC_MEM );
117+ if ( sqlite3GlobalConfig .pPage == 0 || sqlite3GlobalConfig .szPage < 512
118+ || sqlite3GlobalConfig .nPage <=0 ){
119+ sqlite3GlobalConfig .pPage = 0 ;
120+ sqlite3GlobalConfig .szPage = 0 ;
121+ }
122+ rc = sqlite3GlobalConfig .m .xInit (sqlite3GlobalConfig .m .pAppData );
123+ if ( rc != SQLITE_OK ) memset (& mem0 , 0 , sizeof (mem0 ));
124+ /* BEGIN SQLCIPHER */
115125#ifdef SQLITE_HAS_CODEC
116126 /* install wrapping functions for memory management
117127 that will wipe all memory allocated by SQLite
@@ -123,16 +133,6 @@ int sqlite3MallocInit(void){
123133#endif
124134/* END SQLCIPHER */
125135 }
126-
127- memset (& mem0 , 0 , sizeof (mem0 ));
128- mem0 .mutex = sqlite3MutexAlloc (SQLITE_MUTEX_STATIC_MEM );
129- if ( sqlite3GlobalConfig .pPage == 0 || sqlite3GlobalConfig .szPage < 512
130- || sqlite3GlobalConfig .nPage <=0 ){
131- sqlite3GlobalConfig .pPage = 0 ;
132- sqlite3GlobalConfig .szPage = 0 ;
133- }
134- rc = sqlite3GlobalConfig .m .xInit (sqlite3GlobalConfig .m .pAppData );
135- if ( rc != SQLITE_OK ) memset (& mem0 , 0 , sizeof (mem0 ));
136136 return rc ;
137137}
138138
0 commit comments