On Tue, 10 Nov 2026 12:49:49 GMT, Dušan Bálek <[email protected]> wrote:

> Currently, calls to `calloc`/`realloc` in libjimage’s `imageFile.cpp` lack 
> runtime `NULL` checks, which can lead to crashes if memory allocation fails.
> 
> This proposal:
> - Removes memory allocation from the `ImageFileReaderTable` constructor. The 
> table is allocated lazily when the first image is added.
> - Modifies `add(...)` to return `false` if memory allocation fails, allowing 
> its caller to handle insertion failure by deleting the newly opened reader 
> and returning `NULL`.
> - Modifies `remove(...)` to treat table shrinking as optional. If shrinking 
> fails, the table’s allocation and capacity remain unchanged.
> 
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

The postponing of the calloc (now realloc) to the first add confused me first 
but what you propose looks good.

-------------

Marked as reviewed by alanb (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/33818#pullrequestreview-5845379763

Reply via email to