From a91efb2d8d2791f324705e24909af51640ca73e4 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Wed, 21 Nov 2012 13:58:10 -0500 Subject: [PATCH] Add assert and comment for subtle pay-to-script-hash logic --- src/script.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/script.cpp b/src/script.cpp index a40ae5b1..f65508aa 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1658,6 +1658,11 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const C if (!scriptSig.IsPushOnly()) // scriptSig must be literals-only return false; // or validation fails + // stackCopy cannot be empty here, because if it was the + // P2SH HASH <> EQUAL scriptPubKey would be evaluated with + // an empty stack and the EvalScript above would return false. + assert(!stackCopy.empty()); + const valtype& pubKeySerialized = stackCopy.back(); CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end()); popstack(stackCopy);