File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -400,6 +400,7 @@ class CScript : public CScriptBase
400400
401401 CScript& operator +=(const CScript& b)
402402 {
403+ reserve (size () + b.size ());
403404 insert (end (), b.begin (), b.end ());
404405 return *this ;
405406 }
Original file line number Diff line number Diff line change @@ -1172,4 +1172,21 @@ BOOST_AUTO_TEST_CASE(script_FindAndDelete)
11721172 BOOST_CHECK (s == expect);
11731173}
11741174
1175+ BOOST_AUTO_TEST_CASE (script_can_append_self)
1176+ {
1177+ CScript s, d;
1178+
1179+ s = ScriptFromHex (" 00" );
1180+ s += s;
1181+ d = ScriptFromHex (" 0000" );
1182+ BOOST_CHECK (s == d);
1183+
1184+ // check doubling a script that's large enough to require reallocation
1185+ static const char hex[] = " 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f" ;
1186+ s = CScript () << ParseHex (hex) << OP_CHECKSIG;
1187+ d = CScript () << ParseHex (hex) << OP_CHECKSIG << ParseHex (hex) << OP_CHECKSIG;
1188+ s += s;
1189+ BOOST_CHECK (s == d);
1190+ }
1191+
11751192BOOST_AUTO_TEST_SUITE_END ()
You can’t perform that action at this time.
0 commit comments