Skip to content

Commit

Permalink
Fix possible AIOOBE from fuzz test
Browse files Browse the repository at this point in the history
  • Loading branch information
srowen committed Jul 16, 2021
1 parent ad061f0 commit 32331c0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/src/main/java/com/google/zxing/aztec/detector/Detector.java
Expand Up @@ -425,10 +425,12 @@ private boolean isWhiteOrBlackRectangle(Point p1,

int corr = 3;

p1 = new Point(p1.getX() - corr, p1.getY() + corr);
p2 = new Point(p2.getX() - corr, p2.getY() - corr);
p3 = new Point(p3.getX() + corr, p3.getY() - corr);
p4 = new Point(p4.getX() + corr, p4.getY() + corr);
p1 = new Point(Math.max(0, p1.getX() - corr), Math.min(image.getHeight() - 1, p1.getY() + corr));
p2 = new Point(Math.max(0, p2.getX() - corr), Math.max(0, p2.getY() - corr));
p3 = new Point(Math.min(image.getWidth() - 1, p3.getX() + corr),
Math.max(0, Math.min(image.getHeight() - 1, p3.getY() - corr)));
p4 = new Point(Math.min(image.getWidth() - 1, p4.getX() + corr),
Math.min(image.getHeight() - 1, p4.getY() + corr));

int cInit = getColor(p4, p1);

Expand Down

0 comments on commit 32331c0

Please sign in to comment.