Skip to content

Commit

Permalink
Don't panic when a DefBuffer contains less bytes than its size
Browse files Browse the repository at this point in the history
If a DefBuffer contains less bytes than its size, the remaining bytes should
be initialized to `0`. I overlooked that `copy_from_slice` requires that
its two slices are the same size, and so this panics in these cases. This
was picked up by fuzzing.
  • Loading branch information
IsaacWoods committed Dec 30, 2020
1 parent 4286dfc commit 0c64768
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion aml/src/type2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ where
}

let mut buffer = vec![0; buffer_size];
buffer.copy_from_slice(bytes);
(&mut buffer[0..bytes.len()]).copy_from_slice(bytes);
(Ok(buffer), context)
})
}),
Expand Down

0 comments on commit 0c64768

Please sign in to comment.