From 3fa6e8b889cc255451ef147724b3a7efd97e7c4d Mon Sep 17 00:00:00 2001 From: jmestwa-coder Date: Tue, 7 Jul 2026 18:11:08 +0530 Subject: reject non-positive datablock count in aztec correctBits (#2114) --- .../com/google/zxing/aztec/decoder/DecoderTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'core/src/test/java') diff --git a/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java b/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java index 7ccf1cfb6..9098adfac 100644 --- a/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java +++ b/core/src/test/java/com/google/zxing/aztec/decoder/DecoderTest.java @@ -70,6 +70,25 @@ public final class DecoderTest extends Assert { assertEquals("", Decoder.highLevelDecode(new boolean[1])); } + @Test + public void testDecodeNoDataCodewords() { + // a detector result claiming zero (or negative) data codewords must fail as FormatException, + // not IllegalArgumentException / NegativeArraySizeException out of the Reed-Solomon step + BitMatrix matrix = new BitMatrix(151, 151); + for (int nbDatablocks : new int[] { 0, -1 }) { + for (int nbLayers : new int[] { 0, 1, 2 }) { + for (boolean compact : new boolean[] { true, false }) { + try { + new Decoder().decode(new AztecDetectorResult(matrix, NO_POINTS, compact, nbDatablocks, nbLayers)); + fail("nbDatablocks=" + nbDatablocks + " nbLayers=" + nbLayers + " should be rejected"); + } catch (FormatException expected) { + // expected + } + } + } + } + } + @Test public void testAztecResult() throws FormatException { BitMatrix matrix = BitMatrix.parse( -- cgit v1.2.3