diff --git a/src/uu/yes/src/yes.rs b/src/uu/yes/src/yes.rs index 732a1bf5877..13765e75d40 100644 --- a/src/uu/yes/src/yes.rs +++ b/src/uu/yes/src/yes.rs @@ -92,14 +92,12 @@ fn args_into_buffer<'a>( /// Assumes buf holds a single output line forged from the command line arguments, copies it /// repeatedly until the buffer holds as many copies as it can under [`BUF_SIZE`]. fn prepare_buffer(buf: &mut Vec) { - if buf.len() * 2 > BUF_SIZE { - return; - } - - assert!(!buf.is_empty()); - let line_len = buf.len(); - let target_size = line_len * (BUF_SIZE / line_len); + debug_assert!( + line_len > 0, + "buffer is not empty since we have default value y" + ); + let target_size = line_len * (BUF_SIZE / line_len); // 0 if line_len is too large while buf.len() < target_size { let to_copy = std::cmp::min(target_size - buf.len(), buf.len());