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). ------------- Commit messages: - 8395908: Calls to calloc/realloc are not NULL-checked in libjimage imageFile.cpp Changes: https://git.openjdk.org/jdk/pull/33818/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33818&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8395908 Stats: 28 lines in 2 files changed: 15 ins; 3 del; 10 mod Patch: https://git.openjdk.org/jdk/pull/33818.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/33818/head:pull/33818 PR: https://git.openjdk.org/jdk/pull/33818
