No semantic change: reuse stack variable in P2SH evaluation
This commit is contained in:
parent
397b9011c9
commit
ae4151bbad
@ -1107,21 +1107,24 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, unsigne
|
|||||||
if (!scriptSig.IsPushOnly())
|
if (!scriptSig.IsPushOnly())
|
||||||
return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY);
|
return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY);
|
||||||
|
|
||||||
// stackCopy cannot be empty here, because if it was the
|
// Restore stack.
|
||||||
|
swap(stack, stackCopy);
|
||||||
|
|
||||||
|
// stack cannot be empty here, because if it was the
|
||||||
// P2SH HASH <> EQUAL scriptPubKey would be evaluated with
|
// P2SH HASH <> EQUAL scriptPubKey would be evaluated with
|
||||||
// an empty stack and the EvalScript above would return false.
|
// an empty stack and the EvalScript above would return false.
|
||||||
assert(!stackCopy.empty());
|
assert(!stack.empty());
|
||||||
|
|
||||||
const valtype& pubKeySerialized = stackCopy.back();
|
const valtype& pubKeySerialized = stack.back();
|
||||||
CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end());
|
CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end());
|
||||||
popstack(stackCopy);
|
popstack(stack);
|
||||||
|
|
||||||
if (!EvalScript(stackCopy, pubKey2, flags, checker, serror))
|
if (!EvalScript(stack, pubKey2, flags, checker, serror))
|
||||||
// serror is set
|
// serror is set
|
||||||
return false;
|
return false;
|
||||||
if (stackCopy.empty())
|
if (stack.empty())
|
||||||
return set_error(serror, SCRIPT_ERR_EVAL_FALSE);
|
return set_error(serror, SCRIPT_ERR_EVAL_FALSE);
|
||||||
if (!CastToBool(stackCopy.back()))
|
if (!CastToBool(stack.back()))
|
||||||
return set_error(serror, SCRIPT_ERR_EVAL_FALSE);
|
return set_error(serror, SCRIPT_ERR_EVAL_FALSE);
|
||||||
else
|
else
|
||||||
return set_success(serror);
|
return set_success(serror);
|
||||||
|
Loading…
Reference in New Issue
Block a user