Check that we don't access nonexisting union fields
This commit is contained in:
parent
76fe6a41ba
commit
373c362b7e
1 changed files with 5 additions and 1 deletions
|
@ -738,7 +738,11 @@ impl FieldPlacement {
|
|||
|
||||
pub fn offset(&self, i: usize) -> Size {
|
||||
match *self {
|
||||
FieldPlacement::Union(_) => Size::ZERO,
|
||||
FieldPlacement::Union(count) => {
|
||||
assert!(i < count,
|
||||
"Tried to access field {} of union with {} fields", i, count);
|
||||
Size::ZERO
|
||||
},
|
||||
FieldPlacement::Array { stride, count } => {
|
||||
let i = i as u64;
|
||||
assert!(i < count);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue