Skip to content

Commit

Permalink
Fixed panic when sending Frame with non-64 data length
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentRev authored and ericevenchick committed Aug 25, 2024
1 parent d6ce69a commit 5ad62d8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ pub struct Frame {
impl Frame {
fn data_as_array(&self) -> [u8; 64] {
let mut data = [0u8; 64];
data[..64].clone_from_slice(&self.data[..64]);
let len = std::cmp::min(self.data.len(), data.len());
data[..len].copy_from_slice(&self.data[..len]);
data
}
// convert to a frame format expected by the device
Expand Down

0 comments on commit 5ad62d8

Please sign in to comment.