From 31ad3e35dffc264498344725c9ff49b357f4cce5 Mon Sep 17 00:00:00 2001 From: mholt Date: Thu, 5 Dec 2024 07:57:52 -0800 Subject: [PATCH 1/2] minor code change to compare seq len --- src/consensus.rs | 3 +++ src/dual_consensus.rs | 3 +++ 2 files changed, 6 insertions(+) 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()); From eff3354c86aea81747cb8fcadddf401ca1cfbc97 Mon Sep 17 00:00:00 2001 From: mholt Date: Thu, 5 Dec 2024 07:58:20 -0800 Subject: [PATCH 2/2] version bump and changelog update --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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