fix invalid memory access that I added when merging descriptor wallets

Thanks, ubsan + fuzzer!
This commit is contained in:
Andrew Poelstra 2020-12-15 00:38:34 +00:00
parent 98d0ff7035
commit fec99efb8f

View file

@ -506,11 +506,11 @@ bool SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore,
prevTxOut = GetPeginOutputFromWitness(mtx.witness.vtxinwit[i].m_pegin_witness); prevTxOut = GetPeginOutputFromWitness(mtx.witness.vtxinwit[i].m_pegin_witness);
} else { } else {
auto coin = coins.find(txin.prevout); auto coin = coins.find(txin.prevout);
prevTxOut = coin->second.out;
if (coin == coins.end() || coin->second.IsSpent()) { if (coin == coins.end() || coin->second.IsSpent()) {
input_errors[i] = "Input not found or already spent"; input_errors[i] = "Input not found or already spent";
continue; continue;
} }
prevTxOut = coin->second.out;
} }
const CScript& prevPubKey = prevTxOut.scriptPubKey; const CScript& prevPubKey = prevTxOut.scriptPubKey;