diff --git a/base64ct/src/decoder.rs b/base64ct/src/decoder.rs index 6bbb4f78a..1dbb66c65 100644 --- a/base64ct/src/decoder.rs +++ b/base64ct/src/decoder.rs @@ -102,13 +102,8 @@ impl<'i, E: Encoding> Decoder<'i, E> { /// /// # Returns /// - `Ok(bytes)` if the expected amount of data was read - /// - `Err(Error::InvalidLength)` if the exact amount of data couldn't be read, or - /// if the output buffer has a length of 0 + /// - `Err(Error::InvalidLength)` if the exact amount of data couldn't be read pub fn decode<'o>(&mut self, out: &'o mut [u8]) -> Result<&'o [u8], Error> { - if out.is_empty() { - return Err(InvalidLength); - } - if self.is_finished() { return Err(InvalidLength); } @@ -551,8 +546,6 @@ impl<'i> Iterator for LineReader<'i> { mod tests { use crate::{Base64, Base64Unpadded, Decoder, alphabet::Alphabet, test_vectors::*}; - #[cfg(feature = "std")] - use crate::Error::InvalidLength; #[cfg(feature = "std")] use {alloc::vec::Vec, std::io::Read}; @@ -598,16 +591,6 @@ mod tests { assert_eq!(buf.as_slice(), MULTILINE_PADDED_BIN); } - #[cfg(feature = "std")] - #[test] - fn reject_empty_read() { - let mut decoder = Decoder::::new(b"AAAA").unwrap(); - - let mut buf: Vec = vec![]; - - assert_eq!(decoder.decode(&mut buf), Err(InvalidLength)); - } - /// Core functionality of a decoding test #[allow(clippy::arithmetic_side_effects)] fn decode_test<'a, F, V>(expected: &[u8], f: F)