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
parent 4ee149a6db
commit 2980a18572
3 changed files with 35 additions and 2 deletions

View File

@@ -117,7 +117,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()));
}
@@ -128,7 +128,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;