diff --git a/core/src/com/google/zxing/oned/Code128Reader.java b/core/src/com/google/zxing/oned/Code128Reader.java index f39d91f85..0865cc8a5 100644 --- a/core/src/com/google/zxing/oned/Code128Reader.java +++ b/core/src/com/google/zxing/oned/Code128Reader.java @@ -420,10 +420,11 @@ public final class Code128Reader extends OneDReader { // Check for ample whitespace following pattern, but, to do this we first need to remember that // we fudged decoding CODE_STOP since it actually has 7 bars, not 6. There is a black bar left // to read off. Would be slightly better to properly read. Here we just skip it: - while (row.get(nextStart)) { + int width = row.getSize(); + while (nextStart < width && row.get(nextStart)) { nextStart++; } - if (!row.isRange(nextStart, Math.min(row.getSize(), nextStart + (nextStart - lastStart) / 2), + if (!row.isRange(nextStart, Math.min(width, nextStart + (nextStart - lastStart) / 2), false)) { throw ReaderException.getInstance(); }