diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d510ff..f7932cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v0.4.4 +## Bugs +* Fixed a panic caused by input sequences shorter than the offset compare length + # v0.4.3 ## Bugs * Fixed a panic caused by an unchecked `unwrap()` in a `trace!` statement diff --git a/Cargo.toml b/Cargo.toml index 22e79f5..853151a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "waffle_con" -version = "0.4.3" +version = "0.4.4" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/consensus.rs b/src/consensus.rs index 0d400a8..90da501 100644 --- a/src/consensus.rs +++ b/src/consensus.rs @@ -416,6 +416,9 @@ impl ConsensusNode { // build up the search space let con_len = self.consensus.len(); + + // we need to truncate the compare length if it is longer than the sequence + let offset_compare_length = offset_compare_length.min(sequence.len()); // figure out how far back we search let start_delta = offset_window + offset_compare_length; // we search from current back to the offset_window diff --git a/src/dual_consensus.rs b/src/dual_consensus.rs index 21d7a66..8ee4334 100644 --- a/src/dual_consensus.rs +++ b/src/dual_consensus.rs @@ -871,6 +871,9 @@ impl DualConsensusNode { vec![(&mut self.dwfas1, &self.consensus1)] }; + // we need to truncate the compare length if it is longer than the sequence + let offset_compare_length = offset_compare_length.min(sequence.len()); + for (dwfas, consensus) in activators.into_iter() { // make sure everything is currently inactive assert!(dwfas[seq_index].is_none());