Skip to content

Commit 8455e36

Browse files
[test] Avoid reading a potentially uninitialized variable in tx_invalid-test
Prior to this commit the err variable was not guaranteed to be set before the check ... BOOST_CHECK_MESSAGE(err != SCRIPT_ERR_OK, ScriptErrorString(err));
1 parent 02e5308 commit 8455e36

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/test/transaction_tests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ BOOST_AUTO_TEST_CASE(tx_invalid)
189189
// verifyFlags is a comma separated list of script verification flags to apply, or "NONE"
190190
UniValue tests = read_json(std::string(json_tests::tx_invalid, json_tests::tx_invalid + sizeof(json_tests::tx_invalid)));
191191

192-
ScriptError err;
192+
// Initialize to SCRIPT_ERR_OK. The tests expect err to be changed to a
193+
// value other than SCRIPT_ERR_OK.
194+
ScriptError err = SCRIPT_ERR_OK;
193195
for (unsigned int idx = 0; idx < tests.size(); idx++) {
194196
UniValue test = tests[idx];
195197
std::string strTest = test.write();

0 commit comments

Comments
 (0)