diff options
author | drh <drh@noemail.net> | 2015-03-26 17:04:23 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2015-03-26 17:04:23 +0000 |
commit | 592f0cb15e44e69577d1f72b4586093ca48ea7e6 (patch) | |
tree | c311345607fecd40982e2114ee87d75b69cecae2 /src | |
parent | 21aa6a1acbdd445284f4126178dff4ab078ac7db (diff) | |
download | sqlite-592f0cb15e44e69577d1f72b4586093ca48ea7e6.tar.gz sqlite-592f0cb15e44e69577d1f72b4586093ca48ea7e6.zip |
Avoid leaving the malloc subsystem in a partially initialized state if
the low-level initialization callback fails.
FossilOrigin-Name: 3e872011ff5e27738c282f46d2b5803d94fe4b76
Diffstat (limited to 'src')
-rw-r--r-- | src/malloc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/malloc.c b/src/malloc.c index 264d046ec..f06e27d84 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -162,6 +162,7 @@ void sqlite3_soft_heap_limit(int n){ ** Initialize the memory allocation subsystem. */ int sqlite3MallocInit(void){ + int rc; if( sqlite3GlobalConfig.m.xMalloc==0 ){ sqlite3MemSetDefault(); } @@ -197,7 +198,9 @@ int sqlite3MallocInit(void){ sqlite3GlobalConfig.szPage = 0; sqlite3GlobalConfig.nPage = 0; } - return sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData); + rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData); + if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0)); + return rc; } /* |