Fix crash in validateaddress with -disablewallet

Fix a null pointer dereference in validateaddress with -disablewallet. Also add a regression testcase.
This commit is contained in:
Wladimir J. van der Laan
2015-11-09 08:40:46 +01:00
committed by Jack Grigg
parent c2616abb3c
commit 56215c77d8
3 changed files with 35 additions and 2 deletions

View File

@@ -118,7 +118,7 @@ public:
UniValue obj(UniValue::VOBJ);
CPubKey vchPubKey;
obj.push_back(Pair("isscript", false));
if (pwalletMain->GetPubKey(keyID, vchPubKey)) {
if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) {
obj.push_back(Pair("pubkey", HexStr(vchPubKey)));
obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed()));
}
@@ -129,7 +129,7 @@ public:
UniValue obj(UniValue::VOBJ);
CScript subscript;
obj.push_back(Pair("isscript", true));
if (pwalletMain->GetCScript(scriptID, subscript)) {
if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)) {
std::vector<CTxDestination> addresses;
txnouttype whichType;
int nRequired;