From 219372f1dd504b0e187da88e3c0adf25a7e6b8d2 Mon Sep 17 00:00:00 2001 From: ENikS Date: Tue, 23 Sep 2014 13:30:27 -0400 Subject: [PATCH] script: Fix reference into empty vector run time exception Edit by laanwj: `begin_ptr(sourcedata) + sourcedata.size()` -> `end_ptr(sourcedata)` --- src/script/interpreter.cpp | 12 ++++++------ src/test/base58_tests.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index fd3e4f1ff7..d742fb9eb9 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -637,19 +637,19 @@ bool EvalScript(vector >& stack, const CScript& script, co valtype& vch = stacktop(-1); valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160) ? 20 : 32); if (opcode == OP_RIPEMD160) - CRIPEMD160().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); + CRIPEMD160().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash)); else if (opcode == OP_SHA1) - CSHA1().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); + CSHA1().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash)); else if (opcode == OP_SHA256) - CSHA256().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); + CSHA256().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash)); else if (opcode == OP_HASH160) - CHash160().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); + CHash160().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash)); else if (opcode == OP_HASH256) - CHash256().Write(&vch[0], vch.size()).Finalize(&vchHash[0]); + CHash256().Write(begin_ptr(vch), vch.size()).Finalize(begin_ptr(vchHash)); popstack(stack); stack.push_back(vchHash); } - break; + break; case OP_CODESEPARATOR: { diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp index fe68e9e974..58fffb6df4 100644 --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE(base58_EncodeBase58) std::vector sourcedata = ParseHex(test[0].get_str()); std::string base58string = test[1].get_str(); BOOST_CHECK_MESSAGE( - EncodeBase58(&sourcedata[0], &sourcedata[sourcedata.size()]) == base58string, + EncodeBase58(begin_ptr(sourcedata), end_ptr(sourcedata)) == base58string, strTest); } }