From b0c7b629adc6d9f9ea6b8b29db809707deb414ef Mon Sep 17 00:00:00 2001 From: Stephen Lombardo Date: Tue, 30 Oct 2018 09:42:03 -0400 Subject: [PATCH] fix memory initialization --- src/malloc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/malloc.c b/src/malloc.c index 0c8e619..26ae6ec 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -111,7 +111,7 @@ int sqlite3MallocInit(void){ int rc; if( sqlite3GlobalConfig.m.xMalloc==0 ){ sqlite3MemSetDefault(); - + } memset(&mem0, 0, sizeof(mem0)); mem0.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); if( sqlite3GlobalConfig.pPage==0 || sqlite3GlobalConfig.szPage<512 @@ -121,18 +121,17 @@ int sqlite3MallocInit(void){ } rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData); if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0)); - /* BEGIN SQLCIPHER */ +/* BEGIN SQLCIPHER */ #ifdef SQLITE_HAS_CODEC - /* install wrapping functions for memory management - that will wipe all memory allocated by SQLite - when freed */ - { - extern void sqlcipher_init_memmethods(); - sqlcipher_init_memmethods(); - } + /* install wrapping functions for memory management + that will wipe all memory allocated by SQLite + when freed */ + if( rc==SQLITE_OK ) { + extern void sqlcipher_init_memmethods(); + sqlcipher_init_memmethods(); + } #endif /* END SQLCIPHER */ - } return rc; }