Skip to content

Commit

Permalink
Merge pull request gridcoin-community#2480 from barton2526/array_access
Browse files Browse the repository at this point in the history
tests: Don't access out of bounds array index: array[sizeof(array)]
  • Loading branch information
jamescowens authored Apr 9, 2022
2 parents 44d9287 + 5c90f2b commit 711993a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/test/script_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,18 @@ BOOST_AUTO_TEST_CASE(script_PushData)
static const unsigned char pushdata4[] = { OP_PUSHDATA4, 1, 0, 0, 0, 0x5a };

vector<vector<unsigned char> > directStack;
BOOST_CHECK(EvalScript(directStack, CScript(&direct[0], &direct[sizeof(direct)]), CTransaction(), 0, 0));
BOOST_CHECK(EvalScript(directStack, CScript(direct, direct + sizeof(direct)), CTransaction(), 0, 0));

vector<vector<unsigned char> > pushdata1Stack;
BOOST_CHECK(EvalScript(pushdata1Stack, CScript(&pushdata1[0], &pushdata1[sizeof(pushdata1)]), CTransaction(), 0, 0));
BOOST_CHECK(EvalScript(pushdata1Stack, CScript(pushdata1, pushdata1 + sizeof(pushdata1)), CTransaction(), 0, 0));
BOOST_CHECK(pushdata1Stack == directStack);

vector<vector<unsigned char> > pushdata2Stack;
BOOST_CHECK(EvalScript(pushdata2Stack, CScript(&pushdata2[0], &pushdata2[sizeof(pushdata2)]), CTransaction(), 0, 0));
BOOST_CHECK(EvalScript(pushdata2Stack, CScript(pushdata2, pushdata2 + sizeof(pushdata2)), CTransaction(), 0, 0));
BOOST_CHECK(pushdata2Stack == directStack);

vector<vector<unsigned char> > pushdata4Stack;
BOOST_CHECK(EvalScript(pushdata4Stack, CScript(&pushdata4[0], &pushdata4[sizeof(pushdata4)]), CTransaction(), 0, 0));
BOOST_CHECK(EvalScript(pushdata4Stack, CScript(pushdata4, pushdata4 + sizeof(pushdata4)), CTransaction(), 0, 0));
BOOST_CHECK(pushdata4Stack == directStack);
}

Expand Down

0 comments on commit 711993a

Please sign in to comment.