[test] Avoid reading a potentially uninitialized variable in tx_invalid-test (transaction_tests.cpp)#9555
Conversation
0ed1087 to
dbb285a
Compare
|
It is set one line before use, no?
…On Sat, Jan 14, 2017 at 8:45 PM, practicalswift ***@***.***> wrote:
Prior to this commit the err variable was not guaranteed to set prior to
the check ...
BOOST_CHECK_MESSAGE(err != SCRIPT_ERR_OK, ScriptErrorString(err));
... triggering UB.
------------------------------
You can view, comment on, or merge this pull request online at:
#9555
Commit Summary
- [test] Avoid undefined behaviour in tx_invalid-test
(transaction_tests.cpp)
File Changes
- *M* src/test/transaction_tests.cpp
<https://github.com/bitcoin/bitcoin/pull/9555/files#diff-0> (2)
Patch Links:
- https://github.com/bitcoin/bitcoin/pull/9555.patch
- https://github.com/bitcoin/bitcoin/pull/9555.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9555>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGGmvxdY6fMunnH-S0n2t9WF7XiZ_BQhks5rSSXkgaJpZM4LjuLa>
.
|
|
@MarcoFalke Not in the cases ...
... right? :-) |
|
@MarcoFalke After re-reading your comment I think that you might be referring to |
dbb285a to
6087290
Compare
e4c8db6 to
30e6c25
Compare
|
It may be better to leave this be, so memory sanitizers and static analysis can detect cases where we fail to set it? |
30e6c25 to
604228c
Compare
|
@luke-jr Good point about catching cases where we fail to set it. My suggestion is that we initialize to |
…id-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));
604228c to
8455e36
Compare
|
Indeed, I was reading the wrong lines of the file.
utACK 8455e36
|
|
That will still suppress compiler and analyser warnings of using unassigned values. Is there a way we can initialise it, yet tell the compiler/etc to treat the value as uninitialised still? |
|
@luke-jr I don't know if that is possible and/or how to do it, but if possible I'll add such an annotation :-) Let me know if you find any info on how to achieve that |
|
As long as the tests fail when the variable is not assigned the correct value in the code, all is fine. |
|
@MarcoFalke Yes, that should be the case now :-) |
…e in tx_invalid-test (transaction_tests.cpp) 8455e36 [test] Avoid reading a potentially uninitialized variable in tx_invalid-test (practicalswift) Tree-SHA512: 1064cdd5c9e4612a05397a5880535d93dbb18dec4897b4bbda9e6ad78d30f4c72303e4d23159398f1b33545ff5819e739e374d7cde757e402b26c355268a2319
…variable in tx_invalid-test (transaction_tests.cpp) 8455e36 [test] Avoid reading a potentially uninitialized variable in tx_invalid-test (practicalswift) Tree-SHA512: 1064cdd5c9e4612a05397a5880535d93dbb18dec4897b4bbda9e6ad78d30f4c72303e4d23159398f1b33545ff5819e739e374d7cde757e402b26c355268a2319
Prior to this commit the
errvariable was not guaranteed to be set before the check ...