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).

This pull request has now been integrated.

Changeset: eabadaca
Author:    Dušan Bálek <[email protected]>
URL:       
https://git.openjdk.org/jdk/commit/eabadaca2b525355e557716b34f6004f7b0b12b8
Stats:     28 lines in 2 files changed: 15 ins; 3 del; 10 mod

8395908: Calls to calloc/realloc are not NULL-checked in libjimage imageFile.cpp

Reviewed-by: alanb

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

PR: https://git.openjdk.org/jdk/pull/33818

Reply via email to