From 43cc880a9b28e3ebfd4af687cc100e9947c8708c 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 d00ba56ede4be..d32d7e6b4778c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -263,7 +263,9 @@ void PrepareShutdown() } // 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...