diff options
| author | Leo Fernandes <leofernandesmo@gmail.com> | 2025-07-23 01:51:13 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-23 01:51:13 +0300 |
| commit | 9f68e96cedf860c2a2044e5945c240a9b570782d (patch) | |
| tree | 527379cc755a032924a79f7d499f1c88640a1b77 /core/src/test/java/com | |
| parent | 90f503e0c255f55b2838c882a55fb754af15c315 (diff) | |
| download | zxing-9f68e96cedf860c2a2044e5945c240a9b570782d.tar.xz | |
Add input validation for pixel array length in RGBLuminanceSource and add test case for regression (#1961)
Diffstat (limited to 'core/src/test/java/com')
| -rw-r--r-- | core/src/test/java/com/google/zxing/RGBLuminanceSourceTestCase.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/src/test/java/com/google/zxing/RGBLuminanceSourceTestCase.java b/core/src/test/java/com/google/zxing/RGBLuminanceSourceTestCase.java index 97f9794e1..c10ebc0ed 100644 --- a/core/src/test/java/com/google/zxing/RGBLuminanceSourceTestCase.java +++ b/core/src/test/java/com/google/zxing/RGBLuminanceSourceTestCase.java @@ -60,4 +60,19 @@ public final class RGBLuminanceSourceTestCase extends Assert { assertEquals("#+ \n#+#\n#+#\n", SOURCE.toString()); } + @Test(expected = IllegalArgumentException.class) + public void testNullPixelArray() { + // Test regression: null pixel array should throw IllegalArgumentException + new RGBLuminanceSource(3, 3, null); + } + + @Test(expected = IllegalArgumentException.class) + public void testPixelArrayTooSmall() { + // Test regression: pixel array smaller than width * height should throw IllegalArgumentException + int width = 3; + int height = 3; + int[] pixels = new int[width * height - 1]; // One pixel short + new RGBLuminanceSource(width, height, pixels); + } + } |
