Skip to content

Commit

Permalink
Fix objects not being closed on objcopy helper failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Feb 24, 2025
1 parent 0af437a commit 6aaaacb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/objcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,8 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
H5G_info_t ginfo2; /* Group info struct */
hsize_t idx; /* Index over the objects in group */
unsigned cpy_flags; /* Object copy flags */
hid_t oid = H5I_INVALID_HID; /* IDs of objects within group */
hid_t oid2 = H5I_INVALID_HID;

/* Retrieve the object copy flags from the property list, if it's non-DEFAULT */
if (pid != H5P_DEFAULT) {
Expand Down Expand Up @@ -1564,7 +1566,6 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)

/* Extra checks for "real" objects */
if (linfo.type == H5L_TYPE_HARD) {
hid_t oid, oid2; /* IDs of objects within group */
H5O_info2_t oinfo, oinfo2; /* Data model object info */
H5O_native_info_t ninfo, ninfo2; /* Native file format object info */

Expand Down Expand Up @@ -1649,8 +1650,11 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
/* Close objects */
if (H5Oclose(oid) < 0)
TEST_ERROR;
oid = H5I_INVALID_HID;

if (H5Oclose(oid2) < 0)
TEST_ERROR;
oid2 = H5I_INVALID_HID;
} /* end if */
else {
/* Check that both links are the same size */
Expand Down Expand Up @@ -1691,6 +1695,8 @@ compare_groups(hid_t gid, hid_t gid2, hid_t pid, int depth, unsigned copy_flags)
error:
H5E_BEGIN_TRY
{
H5Oclose(oid);
H5Oclose(oid2);
}
H5E_END_TRY
return false;
Expand Down

0 comments on commit 6aaaacb

Please sign in to comment.