aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-07-07 00:54:42 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2017-07-07 10:45:31 -0700
commit0aadc11fd88b298c7af2dfb69763b2c67dc6b7b0 (patch)
tree02bb833749f472a916c9ff5f585af9e94b5326b8 /src/script
parent5af6572534986bf85f6806e2cc66c1f1f8e3c56c (diff)
downloadbitcoin-0aadc11fd88b298c7af2dfb69763b2c67dc6b7b0.tar.xz
Avoid dereference-of-casted-pointer
Diffstat (limited to 'src/script')
-rw-r--r--src/script/interpreter.cpp4
-rw-r--r--src/script/script.h8
2 files changed, 10 insertions, 2 deletions
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index 7149c938fc..8a121774a0 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -1099,7 +1099,7 @@ public:
// Serialize the script
if (nInput != nIn)
// Blank out other inputs' signatures
- ::Serialize(s, CScriptBase());
+ ::Serialize(s, CScript());
else
SerializeScriptCode(s);
// Serialize the nSequence
@@ -1207,7 +1207,7 @@ uint256 SignatureHash(const CScript& scriptCode, const CTransaction& txTo, unsig
// The prevout may already be contained in hashPrevout, and the nSequence
// may already be contain in hashSequence.
ss << txTo.vin[nIn].prevout;
- ss << static_cast<const CScriptBase&>(scriptCode);
+ ss << scriptCode;
ss << amount;
ss << txTo.vin[nIn].nSequence;
// Outputs (none/one/all, depending on flags)
diff --git a/src/script/script.h b/src/script/script.h
index bbb37f049e..d16bfd0e00 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -8,6 +8,7 @@
#include "crypto/common.h"
#include "prevector.h"
+#include "serialize.h"
#include <assert.h>
#include <climits>
@@ -404,6 +405,13 @@ public:
CScript(std::vector<unsigned char>::const_iterator pbegin, std::vector<unsigned char>::const_iterator pend) : CScriptBase(pbegin, pend) { }
CScript(const unsigned char* pbegin, const unsigned char* pend) : CScriptBase(pbegin, pend) { }
+ ADD_SERIALIZE_METHODS;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action) {
+ READWRITE(static_cast<CScriptBase&>(*this));
+ }
+
CScript& operator+=(const CScript& b)
{
insert(end(), b.begin(), b.end());