diff --git a/core/src/main/java/com/google/zxing/qrcode/QRCodeReader.java b/core/src/main/java/com/google/zxing/qrcode/QRCodeReader.java index 310a40926..ebc6b9a7d 100644 --- a/core/src/main/java/com/google/zxing/qrcode/QRCodeReader.java +++ b/core/src/main/java/com/google/zxing/qrcode/QRCodeReader.java @@ -139,6 +139,10 @@ public class QRCodeReader implements Reader { // Special case, where bottom-right module wasn't black so we found something else in the last row // Assume it's a square, so use height as the width right = left + (bottom - top); + if (right >= image.getWidth()) { + // Abort if that would not make sense -- off image + throw NotFoundException.getNotFoundInstance(); + } } int matrixWidth = Math.round((right - left + 1) / moduleSize);