diff --git a/src/init.cpp b/src/init.cpp index 2fca612f4..aa23fbbe9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2174,12 +2174,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) do { try { UnloadBlockIndex(); - delete pcoinsTip; - delete pcoinsdbview; - delete pcoinscatcher; - delete pblocktree; - delete pnotarizations; - pnotarizations = NULL; // Shutdown() deletes it, so never leave it dangling if a reopen below throws + // Shutdown() deletes (and pcoinsTip: flushes) whatever is non-NULL here, so never leave + // a pointer dangling if one of the reopens below throws. + delete pcoinsTip; pcoinsTip = NULL; + delete pcoinsdbview; pcoinsdbview = NULL; + delete pcoinscatcher; pcoinscatcher = NULL; + delete pblocktree; pblocktree = NULL; + delete pnotarizations; pnotarizations = NULL; pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex, dbCompression, dbMaxOpenFiles); pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex);