Added a bit of defensive programming in the AlignmentPattern code. There were real...
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 14 Oct 2008 18:24:23 +0000 (18:24 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 14 Oct 2008 18:24:23 +0000 (18:24 +0000)
Sean, please review.

git-svn-id: http://zxing.googlecode.com/svn/trunk@617 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/qrcode/detector/Detector.java

index 8f06e8d..574d2d1 100644 (file)
@@ -334,6 +334,10 @@ public final class Detector {
     int allowance = (int) (allowanceFactor * overallEstModuleSize);
     int alignmentAreaLeftX = Math.max(0, estAlignmentX - allowance);
     int alignmentAreaRightX = Math.min(image.getWidth() - 1, estAlignmentX + allowance);
+    if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {
+      throw new ReaderException("Alignment pattern is too small to search");
+    }
+
     int alignmentAreaTopY = Math.max(0, estAlignmentY - allowance);
     int alignmentAreaBottomY = Math.min(image.getHeight() - 1, estAlignmentY + allowance);