Skip to content

Commit b0c7b62

Browse files
committed
fix memory initialization
1 parent ca4b36a commit b0c7b62

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

src/malloc.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ int sqlite3MallocInit(void){
111111
int rc;
112112
if( sqlite3GlobalConfig.m.xMalloc==0 ){
113113
sqlite3MemSetDefault();
114-
114+
}
115115
memset(&mem0, 0, sizeof(mem0));
116116
mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
117117
if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512
@@ -121,18 +121,17 @@ int sqlite3MallocInit(void){
121121
}
122122
rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
123123
if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));
124-
/* BEGIN SQLCIPHER */
124+
/* BEGIN SQLCIPHER */
125125
#ifdef SQLITE_HAS_CODEC
126-
/* install wrapping functions for memory management
127-
that will wipe all memory allocated by SQLite
128-
when freed */
129-
{
130-
extern void sqlcipher_init_memmethods();
131-
sqlcipher_init_memmethods();
132-
}
126+
/* install wrapping functions for memory management
127+
that will wipe all memory allocated by SQLite
128+
when freed */
129+
if( rc==SQLITE_OK ) {
130+
extern void sqlcipher_init_memmethods();
131+
sqlcipher_init_memmethods();
132+
}
133133
#endif
134134
/* END SQLCIPHER */
135-
}
136135
return rc;
137136
}
138137

0 commit comments

Comments
 (0)