From 72227ddfae951fac72bb64cec3f342eb56f9ebd1 Mon Sep 17 00:00:00 2001 From: SymmetricChaos <42520289+SymmetricChaos@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:51:16 -0500 Subject: [PATCH] Update run_length_bytes.rs --- codes/src/compression/run_length_bytes.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/codes/src/compression/run_length_bytes.rs b/codes/src/compression/run_length_bytes.rs index 4b1f9f7f..44619dff 100644 --- a/codes/src/compression/run_length_bytes.rs +++ b/codes/src/compression/run_length_bytes.rs @@ -70,6 +70,10 @@ impl Code for RunLengthEncoding { .text_to_bytes(text) .map_err(|_| CodeError::input("invalid input bytes"))?; + if !bytes.len().is_even() { + return Err(CodeError::input("the rle must be an even number of bytes")); + } + Ok(self.output_format.byte_slice_to_text(&rle_to_bytes(&bytes))) } }