From e6e098b7c341159fcbcea23a3c283b7906cf6301 Mon Sep 17 00:00:00 2001 From: mattjala <124107509+mattjala@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:01:15 -0500 Subject: [PATCH] Correct H5VL_t ref count on H5O_refresh_metadata failure (#4636) * Fix bad H5VL_t rc on H5O_refresh_metadata fail * Decrement nrefs before raising error --- src/H5Oflush.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/H5Oflush.c b/src/H5Oflush.c index 1c561d00b8b..dd11c25e7ca 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -235,12 +235,16 @@ H5O_refresh_metadata(H5O_loc_t *oloc, hid_t oid) connector->nrefs++; /* Close object & evict its metadata */ - if (H5O__refresh_metadata_close(oloc, &obj_loc, oid) < 0) + if (H5O__refresh_metadata_close(oloc, &obj_loc, oid) < 0) { + connector->nrefs--; HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object"); + } /* Re-open the object, re-fetching its metadata */ - if (H5O_refresh_metadata_reopen(oid, H5P_DEFAULT, &obj_loc, connector, false) < 0) + if (H5O_refresh_metadata_reopen(oid, H5P_DEFAULT, &obj_loc, connector, false) < 0) { + connector->nrefs--; HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object"); + } /* Restore the number of references on the VOL connector */ connector->nrefs--;