aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2017-09-11 13:40:31 +1000
committerAnthony Towns <aj@erisian.com.au>2017-09-11 13:40:31 +1000
commitd601f16621e55c2f174afea2c5d7d1c9a0c0b969 (patch)
treeb75a7cd430b2010518414f6669dbc04dccea97b0 /src/test
parentee50c9e48786dea0d9df2e45805c25565c100fe3 (diff)
Fix invalid memory access in CScript::operator+=
Diffstat (limited to 'src/test')
-rw-r--r--src/test/script_tests.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp
index 17374edcc4..011a5db795 100644
--- a/src/test/script_tests.cpp
+++ b/src/test/script_tests.cpp
@@ -1451,4 +1451,21 @@ BOOST_AUTO_TEST_CASE(script_HasValidOps)
BOOST_CHECK(!script.HasValidOps());
}
+BOOST_AUTO_TEST_CASE(script_can_append_self)
+{
+ CScript s, d;
+
+ s = ScriptFromHex("00");
+ s += s;
+ d = ScriptFromHex("0000");
+ BOOST_CHECK(s == d);
+
+ // check doubling a script that's large enough to require reallocation
+ static const char hex[] = "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f";
+ s = CScript() << ParseHex(hex) << OP_CHECKSIG;
+ d = CScript() << ParseHex(hex) << OP_CHECKSIG << ParseHex(hex) << OP_CHECKSIG;
+ s += s;
+ BOOST_CHECK(s == d);
+}
+
BOOST_AUTO_TEST_SUITE_END()