dajiaohuang opened a new pull request, #566: URL: https://github.com/apache/commons-imaging/pull/566
Fixes [IMAGING-388](https://issues.apache.org/jira/browse/IMAGING-388). ## What PNG scanline sizing used 32-bit multiplication for `bitsPerPixel * width` and rounded the result to bytes with another `int` expression. For the reported 536,870,921-pixel, 8-bit grayscale row, the product wraps to 72 bits and produces a 9-byte row buffer. Decoding then indexes beyond that buffer. Compute scanline size in `long`, reject results that cannot be represented as a Java array length with `ImagingException`, and use long arithmetic for per-sample offsets. `BitParser` now reports an out-of-row sample as `ImagingException` rather than leaking `ArrayIndexOutOfBoundsException`. ## Tests - Regression verifies 536,870,921 grayscale pixels require a 536,870,921-byte row without allocating that buffer. - Regression verifies unrepresentable scanline lengths and out-of-row/overflowing sample offsets fail with `ImagingException`. - Default Maven build (`mvn`): BUILD SUCCESS; 1,265 tests, 0 failures, 0 errors, 7 skipped. The task-local checkout was normalized to the repository's LF source convention for Checkstyle. ## Contribution checklist - [x] Read the contribution guidelines. - [x] Read the ASF Generative Tooling Guidance. - [x] AI use: OpenAI Codex (gpt-6-luna) assisted with source analysis, implementation, and regression tests. Human operator: `dajiaohuang`. - [x] Ran the default Maven build successfully. - [x] Added behavioral regression tests. - [x] This description explains the issue and change. - [x] Commit subject and body identify the issue and summarize the change. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
