From 38052af55d179686253c334f86e8ca271dddf920 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Mon, 28 Jul 2014 15:58:33 -0300 Subject: [PATCH] handle block db inconsistency more nicely --- src/rpcblockchain.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 9bb74944..9e4d405d 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -149,6 +149,11 @@ Value getblockhash(const Array& params, bool fHelp) throw runtime_error("Block number out of range."); CBlockIndex* pblockindex = FindBlockByHeight(nHeight); + if (pblockindex == NULL) { + string errormsg = "getblockhash internal error: pblockindex == NULL. consider reindexing blocks (program may crash)"; + printf("%s\n",errormsg.c_str()); + throw runtime_error(errormsg); + } return pblockindex->phashBlock->GetHex(); }