Skip to content
Snippets Groups Projects
Commit a4c07b1f authored by Martin Larralde's avatar Martin Larralde
Browse files

Panic when the sequence is too long in AVX2 and SSE2 `best_position` code

parent eaf43961
No related branches found
No related tags found
No related merge requests found
......@@ -113,7 +113,12 @@ unsafe fn score_avx2(
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
#[target_feature(enable = "avx2")]
unsafe fn best_position_avx2(scores: &StripedScores<<Avx2 as Backend>::LANES>) -> Option<usize> {
if scores.len() == 0 {
if scores.len() > u32::MAX as usize {
panic!(
"This implementation only supports sequences with at most {} positions, found a sequence with {} positions. Contact the developers at https://github.com/althonos/lightmotif.",
u32::MAX, scores.len()
);
} else if scores.len() == 0 {
None
} else {
let data = scores.matrix();
......
......@@ -94,7 +94,12 @@ where
<C as Rem<U16>>::Output: Zero,
<C as Div<U16>>::Output: Unsigned,
{
if scores.len() == 0 {
if scores.len() > u32::MAX as usize {
panic!(
"This implementation only supports sequences with at most {} positions, found a equence with {} positions. Contact the developers at https://github.com/althonos/lightmotif.",
u32::MAX, scores.len()
);
} else if scores.len() == 0 {
None
} else {
let data = scores.matrix();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment