From 954d2e7201fcea7a95c5a95be574a8c0a1f16ce1 Mon Sep 17 00:00:00 2001 From: Ruben Dario Ponticelli Date: Wed, 9 Jul 2014 21:37:27 -0300 Subject: [PATCH] Avoid a segfault on getblock if it can't read a block from disk. --- src/rpcblockchain.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index a67f266a1..253693e62 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -276,7 +276,9 @@ Value getblock(const Array& params, bool fHelp) CBlock block; CBlockIndex* pblockindex = mapBlockIndex[hash]; - ReadBlockFromDisk(block, pblockindex); + + if(!ReadBlockFromDisk(block, pblockindex)) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); if (!fVerbose) {