Commit b069fae
committed
Fix use-after-poison in UsefulAnalyzer's reverse CFG walk.
UsefulAnalyzer::AnalyzeCFGBlock walks a block's CFGElements in reverse,
but started the iterator at block.end() and dereferenced it, using
block.begin() - 1 as the loop sentinel. Both are invalid iterators: end()
is one past the last element and begin() - 1 is out of bounds. Reading a
CFGElement's PointerIntPair through them is undefined; under
-fsanitize=address the container annotations on the element storage turn
it into a use-after-poison (e.g. Analyses/UsefulForward.cpp).
Use rbegin()/rend() instead: a plain forward walk over reverse iterators
visits the same elements in the same order without ever dereferencing
end() or forming the out-of-bounds sentinel.1 parent f5f33c1 commit b069fae
1 file changed
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
53 | 54 | | |
54 | | - | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
0 commit comments