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 @@ -420,6 +420,7 @@ class CScript : public CScriptBase
420
420
421
421
CScript& operator +=(const CScript& b)
422
422
{
423
+ reserve (size () + b.size ());
423
424
insert (end (), b.begin (), b.end ());
424
425
return *this ;
425
426
}
Original file line number Diff line number Diff line change @@ -1451,4 +1451,21 @@ BOOST_AUTO_TEST_CASE(script_HasValidOps)
1451
1451
BOOST_CHECK (!script.HasValidOps ());
1452
1452
}
1453
1453
1454
+ BOOST_AUTO_TEST_CASE (script_can_append_self)
1455
+ {
1456
+ CScript s, d;
1457
+
1458
+ s = ScriptFromHex (" 00" );
1459
+ s += s;
1460
+ d = ScriptFromHex (" 0000" );
1461
+ BOOST_CHECK (s == d);
1462
+
1463
+ // check doubling a script that's large enough to require reallocation
1464
+ static const char hex[] = " 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f" ;
1465
+ s = CScript () << ParseHex (hex) << OP_CHECKSIG;
1466
+ d = CScript () << ParseHex (hex) << OP_CHECKSIG << ParseHex (hex) << OP_CHECKSIG;
1467
+ s += s;
1468
+ BOOST_CHECK (s == d);
1469
+ }
1470
+
1454
1471
BOOST_AUTO_TEST_SUITE_END ()
You can’t perform that action at this time.
0 commit comments