Skip to content

Adds check for H5I_get_type() returned value - #6750

Open
bmribler wants to merge 3 commits into
HDFGroup:developfrom
bmribler:fix_github_4764
Open

bmribler wants to merge 3 commits into
HDFGroup:developfrom
bmribler:fix_github_4764

Conversation

@bmribler

@bmribler bmribler commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

The returned value from H5I_get_type() is not checked in many functions in this kind of statement. This can potentially cause issues further down if one of those H5I_get_type() fails.

Fixes GH-4764
(replaces PR #6711 dues to issues with clang-format)

bmribler and others added 2 commits October 19, 2026 00:54
The returned value from H5I_get_type() is not checked in many functions in this kind of statement. This can potentially cause issues further down if one of those H5I_get_type() fails.

Fixes HDFGroupGH-4764
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Checklist

This PR touches the following areas. Each needs a sign-off
from its listed owners before merging.

@bmribler
bmribler requested a review from glennsong09 October 19, 2026 06:55
@github-actions
github-actions Bot removed the request for review from fortnern October 19, 2026 06:55
@bmribler
bmribler requested a review from fortnern October 19, 2026 15:35
@github-actions
github-actions Bot removed the request for review from glennsong09 October 19, 2026 15:35
@bmribler bmribler added the Component - C Library Core C library issues (usually in the src directory) label Oct 19, 2026
@bmribler bmribler moved this from To be triaged to In progress in HDF5 - TRIAGE & TRACK Oct 19, 2026
@bmribler bmribler added this to the HDF5 2.3.0 milestone Oct 19, 2026
Comment thread src/H5A.c
if (H5I_ATTR == H5I_get_type(loc_id))
if (H5I_BADID == (vol_obj_type = H5I_get_type(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier");
if (H5I_ATTR == vol_obj_type)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me this still isn't a very good check. It should check the ID against a list of valid classes, not a list of invalid classes. Looking at the enum definition it looks like most values don't have a valid location. I would suggest creating a macro for checking if an ID type has a valid location. I believe you could just check if (type >= H5I_FILE) && (type <= H5I_MAP)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also not convinced the temporary variables are necessary

@fortnern fortnern left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component - C Library Core C library issues (usually in the src directory)

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

Returned value from H5I_get_type() is not checked

2 participants