From b3941e251ba1d5030195f06a73594848e892f76c Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Mon, 30 Aug 2021 13:24:58 -0500 Subject: [PATCH] Possible fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=37853 --- .../main/java/com/google/zxing/maxicode/MaxiCodeReader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/google/zxing/maxicode/MaxiCodeReader.java b/core/src/main/java/com/google/zxing/maxicode/MaxiCodeReader.java index 10319007c..1327215be 100644 --- a/core/src/main/java/com/google/zxing/maxicode/MaxiCodeReader.java +++ b/core/src/main/java/com/google/zxing/maxicode/MaxiCodeReader.java @@ -98,13 +98,13 @@ public final class MaxiCodeReader implements Reader { // Now just read off the bits BitMatrix bits = new BitMatrix(MATRIX_WIDTH, MATRIX_HEIGHT); for (int y = 0; y < MATRIX_HEIGHT; y++) { - int iy = top + (y * height + height / 2) / MATRIX_HEIGHT; + int iy = Math.min(top + (y * height + height / 2) / MATRIX_HEIGHT, height - 1); for (int x = 0; x < MATRIX_WIDTH; x++) { // srowen: I don't quite understand why the formula below is necessary, but it // can walk off the image if left + width = the right boundary. So cap it. int ix = left + Math.min( (x * width + width / 2 + (y & 0x01) * width / 2) / MATRIX_WIDTH, - width); + width - 1); if (image.get(ix, iy)) { bits.set(x, y); }