Browse Source

Auto merge of #2526 - bitcartel:2480_segfault_zeroconf_from_zaddr, r=daira

Fixes #2480 where missing map entry would cause a segfault.

`wtxHeight = mapBlockIndex[wtx.hashBlock]->nHeight;` results in undefined behaviour when the block hash is not present in the map, returning a null value which is dereferenced via `->nHeight`.  This error is triggered by a zero-conf wallet transaction which has not been mined yet.  As discussed in #2480, on some systems there is a segfault whilst on others there is a silent exit.  This makes it difficult to write a test, but the fix has been tested empirically to confirm an exception is thrown.  This PR fixes the segfault and complements #2525 which prevents a user from sending from a zaddr with minconf 0.
pull/4/head
Homu 7 years ago
parent
commit
d6e6f51724
  1. 4
      src/wallet/asyncrpcoperation_sendmany.cpp

4
src/wallet/asyncrpcoperation_sendmany.cpp

@ -593,6 +593,10 @@ bool AsyncRPCOperation_sendmany::main_impl() {
{
LOCK2(cs_main, pwalletMain->cs_wallet);
const CWalletTx& wtx = pwalletMain->mapWallet[jso.hash];
// Zero confirmaton notes belong to transactions which have not yet been mined
if (mapBlockIndex.find(wtx.hashBlock) == mapBlockIndex.end()) {
throw JSONRPCError(RPC_WALLET_ERROR, strprintf("mapBlockIndex does not contain block hash %s", wtx.hashBlock.ToString()));
}
wtxHeight = mapBlockIndex[wtx.hashBlock]->nHeight;
wtxDepth = wtx.GetDepthInMainChain();
}

Loading…
Cancel
Save