From: srowen Date: Mon, 7 Apr 2008 22:05:40 +0000 (+0000) Subject: Workaround for codes that fail to include (required) final TERMINATOR mode indicator X-Git-Url: http://git.rot13.org/?p=zxing.git;a=commitdiff_plain;h=8bc57a673d76441ad44b8b1376dce8a565c07fe4 Workaround for codes that fail to include (required) final TERMINATOR mode indicator git-svn-id: http://zxing.googlecode.com/svn/trunk@351 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- diff --git a/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java b/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java index b53a7cf5..d253ef94 100644 --- a/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java +++ b/core/src/com/google/zxing/qrcode/decoder/DecodedBitStreamParser.java @@ -60,7 +60,12 @@ final class DecodedBitStreamParser { Mode mode; do { // While still another segment to read... - mode = Mode.forBits(bits.readBits(4)); // mode is encoded by 4 bits + if (bits.available() == 0) { + // OK, assume we're done. Really, a TERMINATOR mode should have been recorded here + mode = Mode.TERMINATOR; + } else { + mode = Mode.forBits(bits.readBits(4)); // mode is encoded by 4 bits + } if (!mode.equals(Mode.TERMINATOR)) { // How many characters will follow, encoded in this mode? int count = bits.readBits(mode.getCharacterCountBits(version));