mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-25 20:02:34 +00:00
Merge pull request #29 from Olssdani/fix_out_of_bound_index
Fixed crash because of out of bound indices for MaxiCode.
This commit is contained in:
@@ -255,7 +255,7 @@ impl BitMatrix {
|
||||
|
||||
/// Confusingly returns true if the requested element is out of bounds
|
||||
pub fn check_in_bounds(&self, x: u32, y: u32) -> bool {
|
||||
(self.get_offset(y, x)) > self.bits.len()
|
||||
(self.get_offset(y, x)) >= self.bits.len()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -281,7 +281,9 @@ impl Circle<'_> {
|
||||
// count left
|
||||
while {
|
||||
let point = get_point(self.center, (x, y), rotation);
|
||||
!self.image.get(point.x as u32, point.y as u32) && x > 0
|
||||
!self.image.check_in_bounds(point.x as u32, point.y as u32)
|
||||
&& !self.image.get(point.x as u32, point.y as u32)
|
||||
&& x > 0
|
||||
} {
|
||||
x -= 1;
|
||||
length += 1;
|
||||
@@ -293,7 +295,8 @@ impl Circle<'_> {
|
||||
// count right
|
||||
while {
|
||||
let point = get_point(self.center, (x, y), rotation);
|
||||
!self.image.get(point.x as u32, point.y as u32)
|
||||
!self.image.check_in_bounds(point.x as u32, point.y as u32)
|
||||
&& !self.image.get(point.x as u32, point.y as u32)
|
||||
} {
|
||||
x += 1;
|
||||
length += 1;
|
||||
|
||||
Reference in New Issue
Block a user