diff --git a/core/src/main/java/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java b/core/src/main/java/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java index a34e5231a..f732edd92 100644 --- a/core/src/main/java/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java +++ b/core/src/main/java/com/google/zxing/pdf417/decoder/DecodedBitStreamParser.java @@ -104,11 +104,10 @@ final class DecodedBitStreamParser { static DecoderResult decode(int[] codewords, String ecLevel) throws FormatException { StringBuilder result = new StringBuilder(codewords.length * 2); Charset encoding = StandardCharsets.ISO_8859_1; - // Get compaction mode - int codeIndex = 1; - int code = codewords[codeIndex++]; + int codeIndex = textCompaction(codewords, 1, result); PDF417ResultMetadata resultMetadata = new PDF417ResultMetadata(); while (codeIndex < codewords[0]) { + int code = codewords[codeIndex++]; switch (code) { case TEXT_COMPACTION_MODE_LATCH: codeIndex = textCompaction(codewords, codeIndex, result); @@ -154,11 +153,6 @@ final class DecodedBitStreamParser { codeIndex = textCompaction(codewords, codeIndex, result); break; } - if (codeIndex < codewords.length) { - code = codewords[codeIndex++]; - } else { - throw FormatException.getFormatInstance(); - } } if (result.length() == 0 && resultMetadata.getFileId() == null) { throw FormatException.getFormatInstance();