From 3071f2072eddcecf2d06e89038f21406f13307f0 Mon Sep 17 00:00:00 2001 From: Casey Fleser Date: Thu, 20 Feb 2014 06:54:45 -0600 Subject: [PATCH] a few more tweaks --- src/compat.h | 1 + src/script.cpp | 12 +++++------- src/script.h | 14 +++++++------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/compat.h b/src/compat.h index 3f61a9964..25aa6d89b 100644 --- a/src/compat.h +++ b/src/compat.h @@ -28,6 +28,7 @@ #endif #if MAC_OSX +#undef MSG_NOSIGNAL // undef prior to redefinition eliminates warnings #define MSG_NOSIGNAL SO_NOSIGPIPE #endif diff --git a/src/script.cpp b/src/script.cpp index cdd2dc668..adeeffa57 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -31,8 +31,6 @@ static const CBigNum bnFalse(0); static const CBigNum bnTrue(1); static const size_t nMaxNumSize = 4; -#undef printf - CBigNum CastToBigNum(const valtype& vch) { if (vch.size() > nMaxNumSize) @@ -1197,9 +1195,9 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vectorGetOp(pc2, opcode2)) // templates push no data, no need to get vch + if (!testScript->GetOp2(pc2, opcode2, NULL)) // templates push no data, no need to get vch break; // Template matching opcodes: @@ -1208,10 +1206,10 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector= 33 && vch1.size() <= 120) { vSolutionsRet.push_back(vch1); - if (!script1.GetOp(pc1, opcode1, vch1)) + if (!script1.GetOp2(pc1, opcode1, &vch1)) break; } - if (!testScript->GetOp(pc2, opcode2)) + if (!testScript->GetOp2(pc2, opcode2, NULL)) break; // Normal situation is to fall through // to other if/else statements @@ -1812,7 +1810,7 @@ unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const return subscript.GetSigOpCount(true); } -inline bool CScript::IsPayToScriptHash() const +bool CScript::IsPayToScriptHash() const { // Extra-fast test for pay-to-script-hash CScripts: return (this->size() == 23 && diff --git a/src/script.h b/src/script.h index 62225e564..a174fcd96 100644 --- a/src/script.h +++ b/src/script.h @@ -426,14 +426,14 @@ public: bool GetOp2(const_iterator& pc, opcodetype& opcodeRet, std::vector* pvchRet) const { + const_iterator scriptEnd = end(); + opcodeRet = OP_INVALIDOPCODE; if (pvchRet) pvchRet->clear(); - if (pc >= end()) - return false; // Read instruction - if (end() - pc < 1) + if (scriptEnd - pc < 1) return false; unsigned int opcode = *pc++; @@ -447,13 +447,13 @@ public: } else if (opcode == OP_PUSHDATA1) { - if (end() - pc < 1) + if (scriptEnd - pc < 1) return false; nSize = *pc++; } else if (opcode == OP_PUSHDATA2) { - if (end() - pc < 2) + if (scriptEnd - pc < 2) return false; nSize = 0; memcpy(&nSize, &pc[0], 2); @@ -461,12 +461,12 @@ public: } else if (opcode == OP_PUSHDATA4) { - if (end() - pc < 4) + if (scriptEnd - pc < 4) return false; memcpy(&nSize, &pc[0], 4); pc += 4; } - if (end() - pc < 0 || (unsigned int)(end() - pc) < nSize) + if (scriptEnd - pc < 0 || (unsigned int)(scriptEnd - pc) < nSize) return false; if (pvchRet) pvchRet->assign(pc, pc + nSize);