Commit 24b13aa
committed
Make make_bitflags! sound even when dirty tricks are employed
Previously, the macro relied on an expression of the form Enum::Variant
always being a variant of the enum. However, it may also be an
associated integer constant, in which case we don't have any
guarantee that the value only contains bits valid for this enum.
Thus, adverserial input to the macro could create a `BitFlags<Enum>`
with bits that don't correspond to any of the enum variants. Iterating
over such a value would then cause UB. The debug formatter is also
affected, as internally it iterates over the value being formatted.1 parent 467fe56 commit 24b13aa
File tree
3 files changed
+32
-1
lines changed- src
- test_suite/ui
3 files changed
+32
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
406 | 409 | | |
407 | 410 | | |
408 | 411 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments