Skip to content

Commit 0c64768

Browse files
committed
Don't panic when a DefBuffer contains less bytes than its size
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.
1 parent 4286dfc commit 0c64768

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

aml/src/type2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ where
108108
}
109109

110110
let mut buffer = vec![0; buffer_size];
111-
buffer.copy_from_slice(bytes);
111+
(&mut buffer[0..bytes.len()]).copy_from_slice(bytes);
112112
(Ok(buffer), context)
113113
})
114114
}),

0 commit comments

Comments
 (0)