Skip to content

Commit 75ca397

Browse files
committed
fix: fix and test for rxing-core#58
1 parent 87ff09b commit 75ca397

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

src/maxicode/detector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ fn find_concentric_circles(image: &BitMatrix) -> Option<Vec<Circle>> {
395395

396396
// find things that might be bullseye patterns, we start 6 in because a bullseye is at least six pixels in diameter
397397
let mut row = 6;
398-
while row < image.getHeight() - 6 {
398+
while image.getHeight() >= 6 && row < image.getHeight() - 6 {
399399
let mut current_column = 6;
400400
while current_column < image.getWidth() - 6 {
401401
// check if we can find something that looks like a bullseye

src/oned/one_d_reader.rs

+4
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ pub trait OneDReader: Reader {
175175
row: &[u8],
176176
hints: &DecodingHintDictionary,
177177
) -> Result<RXingResult> {
178+
if row.len() == 0 {
179+
return Err(Exceptions::NOT_FOUND);
180+
}
181+
178182
let new_row = pad_bitarray(row, Self::QUIET_ZONE);
179183

180184
self.decode_row(rowNumber, &new_row, hints)

src/oned/rss/expanded/rss_expanded_reader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::{
3131
oned::{
3232
record_pattern, record_pattern_in_reverse,
3333
rss::{
34-
rss_utils, AbstractRSSReaderTrait, DataCharacter, DataCharacterTrait, FinderPattern
34+
rss_utils, AbstractRSSReaderTrait, DataCharacter, DataCharacterTrait, FinderPattern,
3535
},
3636
OneDReader,
3737
},
Loading

tests/github_issues.rs

+28
Original file line numberDiff line numberDiff line change
@@ -553,3 +553,31 @@ fn issue_51_multiple_detection() {
553553
results.len()
554554
);
555555
}
556+
557+
#[cfg(feature = "image")]
558+
#[test]
559+
fn issue_58() {
560+
use rxing::{DecodingHintDictionary, Exceptions};
561+
562+
let mut hints: DecodingHintDictionary = DecodingHintDictionary::new();
563+
hints.insert(
564+
rxing::DecodeHintType::TRY_HARDER,
565+
rxing::DecodeHintValue::TryHarder(true),
566+
);
567+
assert!(rxing::helpers::detect_multiple_in_file_with_hints(
568+
"test_resources/blackbox/github_issue_cases/empty_issue_58.png",
569+
&mut hints
570+
)
571+
.is_err_and(|e| { e == Exceptions::NOT_FOUND }));
572+
573+
hints.insert(
574+
rxing::DecodeHintType::PURE_BARCODE,
575+
rxing::DecodeHintValue::PureBarcode(true),
576+
);
577+
578+
assert!(rxing::helpers::detect_multiple_in_file_with_hints(
579+
"test_resources/blackbox/github_issue_cases/empty_issue_58.png",
580+
&mut hints
581+
)
582+
.is_err_and(|e| { e == Exceptions::NOT_FOUND }));
583+
}

0 commit comments

Comments
 (0)