aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-04-27 10:35:32 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-05-13 19:58:20 -0400
commit7777f2a4bb1f9d843bc50a4e35085cfbb2808780 (patch)
treea4bde70689d7d39b7e551d18ff62260265b8cde8 /src/rpc
parentfa5ceb25fce2200edf6b8ebfa6d4f01ed6774b95 (diff)
miner: Avoid stack-use-after-return in validationinterface
This is achieved by switching to a shared_ptr. Also, switch the validationinterfaces in the tests to use shared_ptrs for the same reason.
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/mining.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 05d3fd6afb..8e752e5e83 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -874,7 +874,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
return result;
}
-class submitblock_StateCatcher : public CValidationInterface
+class submitblock_StateCatcher final : public CValidationInterface
{
public:
uint256 hash;
@@ -942,17 +942,17 @@ static UniValue submitblock(const JSONRPCRequest& request)
}
bool new_block;
- submitblock_StateCatcher sc(block.GetHash());
- RegisterValidationInterface(&sc);
+ auto sc = std::make_shared<submitblock_StateCatcher>(block.GetHash());
+ RegisterSharedValidationInterface(sc);
bool accepted = ProcessNewBlock(Params(), blockptr, /* fForceProcessing */ true, /* fNewBlock */ &new_block);
- UnregisterValidationInterface(&sc);
+ UnregisterSharedValidationInterface(sc);
if (!new_block && accepted) {
return "duplicate";
}
- if (!sc.found) {
+ if (!sc->found) {
return "inconclusive";
}
- return BIP22ValidationResult(sc.state);
+ return BIP22ValidationResult(sc->state);
}
static UniValue submitheader(const JSONRPCRequest& request)