Issue 311 fix
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 5 Jan 2010 09:40:54 +0000 (09:40 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 5 Jan 2010 09:40:54 +0000 (09:40 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@1174 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/oned/Code128Reader.java

index f39d91f..0865cc8 100644 (file)
@@ -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();
     }