Files
hdf5/java
9eaec3e81a Fix JNI datatype ID leak in h5str_detect_vlen_str() (#6522)
* Fix JNI datatype ID leak in h5str_detect_vlen_str()

The JNI H5Dread/H5Dwrite/H5Aread/H5Awrite wrappers call h5str_detect_vlen()
on the memory type. For an H5T_ARRAY/H5T_VLEN of a fixed (non-vlen-string)
base type, h5str_detect_vlen_str() acquired the base type via H5Tget_super()
but only closed it when the recursive check returned 1 or a negative error.
When the recursive call returned 0 because no vlen string was found, the base type ID
was leaked.

This PR changes h5str_detect_vlen_str() to close the id unconditionally after the recursive check,
in the same style as the compound-member case in the same function.

A JNI regression test exists at TestH5D.testH5DArray_super_no_id_leak, which reads
an H5T_ARRAY-of-int dataset in a loop and asserts via H5Fget_obj_count() that
no datatype IDs leak.

* Assert non-negative H5Fget_obj_count in array datatype ID leak test

Guard the before/after open-datatype counts against a negative
(failed) H5Fget_obj_count return, which would otherwise let the
equality check pass spuriously. Keep the count scoped to
H5F_OBJ_ALL: the leaked IDs are transient datatypes not attached to
any file, so a per-file count would not see them.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Modify CHANGELOG entry

* Modify CHANGELOG again

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: H. Joe Lee <hyoklee@hdfgroup.org>
2026-07-21 11:41:43 -05:00
..
2025-03-18 11:09:10 -05:00