Conversation
… failure (HDFFV-6386) When H5O__cache_deserialize() fails after continuation messages have already been accumulated into cont_msg_info->msgs (e.g. the v1 'v1_pfx_nmesgs < oh->nmesgs' check at H5Ocache.c:305), it returned NULL while leaving the caller's H5O_protect() with oh == NULL. The existing cleanup in H5O_protect() only frees cont_msg_info->msgs when oh != NULL, so the continuation-message array was leaked. Free cont_msg_info->msgs in H5O__cache_deserialize()'s own done block on error. H5FL_seq_free() returns NULL, so this is safe against a double-free with the caller's guarded free. Found by OSS-Fuzz via the matio project's fuzzer (see HDFGroup#6386).
tbeu
requested review from
fortnern,
glennsong09,
jhendersonHDF,
mattjala and
vchoi-hdfgroup
as code owners
August 18, 2026 20:55
github-actions
Bot
removed request for
fortnern,
jhendersonHDF,
mattjala and
vchoi-hdfgroup
August 18, 2026 22:06
Contributor
Review ChecklistThis PR touches the following areas. Each needs a sign-off
|
Contributor
|
This pull request has had no activity for 30 days and has been marked stale. Push a commit or comment to keep it open, or it will be flagged for maintainer review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a memory leak reported by OSS-Fuzz via the matio project's fuzzer (closes #6386).
\
Direct leak of 56 byte(s) ... allocated from:
# 3 H5O__add_cont_msg hdf5/src/H5Ocache.c
# 4 H5O__chunk_deserialize hdf5/src/H5Ocache.c
# 5 H5O__cache_deserialize hdf5/src/H5Ocache.c
...
# 17 H5Rdereference2
\\
Root cause
\H5O__cache_deserialize()\ allocates the continuation-message array
(\cont_msg_info->msgs, via \H5O__add_cont_msg()\ -> \H5FL_SEQ_REALLOC) while parsing the first object-header chunk. The caller \H5O_protect()\ only frees that array on the success path (H5Ocache.c:1075) or on failure *when \oh != NULL* (rule at H5Ocache.c:1142). When the deserialize fails after continuation messages were accumulated (e.g. the v1 \�1_pfx_nmesgs < oh->nmesgs\ check at H5Ocache.c:305), \H5O__cache_deserialize()\ returns \NULL\ and \H5O_protect()'s \oh\ stays \NULL, so its cleanup is skipped and the 56-byte array leaks.
Fix
Free \cont_msg_info->msgs\ in \H5O__cache_deserialize()'s own \done\ block on error. \H5FL_seq_free()\ returns \NULL, so this is safe against a double-free with the caller's guarded free (which becomes a no-op once the array is \NULL).
Verification
Compiles cleanly in both Release and Debug \hdf5-static\ builds and links into a Debug repro exercising matio's exact API paths (\H5Oget_info_by_name3\ + \H5Rdereference2\ on reference datasets). The leak is specific to v1 object headers (the post-continuation \�1_pfx_nmesgs < oh->nmesgs\ check), which is why the leak manifests in the 2.2.0 OSS-Fuzz environment described in the issue.
Checklist