Skip to content

Commit 8ba52a1

Browse files
authored
Merge pull request #84 from forzafedor/fix-subtract-with-overflow-in-readsymmetricpattern
Fix subtract with overflow in readsymmetricpattern
2 parents a50fd6a + f682ade commit 8ba52a1

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/common/cpp_essentials/concentric_finder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn ReadSymmetricPattern<const N: usize, Cursor: BitMatrixCursorTrait>(
7373
return None;
7474
}
7575
}
76-
res[s_2 as usize] -= 1; // the starting pixel has been counted twice, fix this
76+
res[s_2 as usize] = res[s_2 as usize].saturating_sub(1); // the starting pixel has been counted twice, fix this
7777

7878
Some(res)
7979
}

tests/github_issues.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,3 +700,19 @@ fn issue_78_subtract_with_overflow() {
700700

701701
rxing::helpers::detect_multiple_in_luma_with_hints(data_3, 672, 504, &mut hints).unwrap_or_default();
702702
}
703+
704+
#[cfg(feature = "image")]
705+
#[test]
706+
fn issue_83_subtract_with_overflow() {
707+
use rxing::DecodeHints;
708+
709+
let mut hints: DecodeHints =
710+
DecodeHints::default().with(rxing::DecodeHintValue::TryHarder(true));
711+
712+
let mut data = Vec::new();
713+
std::fs::File::open("test_resources/blackbox/github_issue_cases/subtract-with-overflow-readsymmetricpattern-issue-83.bin")
714+
.unwrap()
715+
.read_to_end(&mut data)
716+
.unwrap();
717+
rxing::helpers::detect_multiple_in_luma_with_hints(data, 75, 80, &mut hints).unwrap_or_default();
718+
}

0 commit comments

Comments
 (0)