Skip to content

Commit 98c84bc

Browse files
committed
add panics section to digest_pad docs
1 parent d046ce2 commit 98c84bc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

block-buffer/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,19 @@ where
256256
/// Compress remaining data after padding it with `delim`, zeros and
257257
/// the `suffix` bytes. If there is not enough unused space, `compress`
258258
/// will be called twice.
259+
///
260+
/// # Panics
261+
/// If suffix length is bigger than block size.
259262
#[inline(always)]
260263
pub fn digest_pad(
261264
&mut self,
262265
delim: u8,
263266
suffix: &[u8],
264267
mut compress: impl FnMut(&Block<BlockSize>),
265268
) {
269+
if suffix.len() > BlockSize::USIZE {
270+
panic!("suffix is too long");
271+
}
266272
let pos = self.get_pos();
267273
self.buffer[pos] = delim;
268274
for b in &mut self.buffer[pos + 1..] {

0 commit comments

Comments
 (0)