Skip to content

Commit

Permalink
Update run_length_bytes.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
SymmetricChaos committed Nov 21, 2024
1 parent 6969b63 commit 72227dd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions codes/src/compression/run_length_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
}
Expand Down

0 comments on commit 72227dd

Please sign in to comment.