From c0025d0a92e438155901438580e4d2ebb376b951 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 15 Jul 2017 20:03:11 -0400 Subject: [PATCH] Fix segfault when shutting down before fully loading This was introduced by 3192975f1d177aa9f0bbd823c6387cfbfa943610. It can be triggered easily when canceling DB upgrade from pre-per-utxo. --- src/init.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 5b7379e16..2ca3ec17a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -216,7 +216,9 @@ void Shutdown() } // FlushStateToDisk generates a SetBestChain callback, which we should avoid missing - FlushStateToDisk(); + if (pcoinsTip != nullptr) { + FlushStateToDisk(); + } // After there are no more peers/RPC left to give us new data which may generate // CValidationInterface callbacks, flush them...