diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2020-09-08 21:59:33 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2020-09-08 21:59:33 (GMT) |
commit | 09981b58d800d784a2aa7e3ea5f7f1cad576e8db (patch) | |
tree | c95c14078556f0f7630259c5824f6daf76f3520c | |
parent | f58c2c5cced54d0dbbd72c49bd5dd03c28865196 (diff) | |
download | hdf5-09981b58d800d784a2aa7e3ea5f7f1cad576e8db.zip hdf5-09981b58d800d784a2aa7e3ea5f7f1cad576e8db.tar.gz hdf5-09981b58d800d784a2aa7e3ea5f7f1cad576e8db.tar.bz2 |
Fixes a leak of the metadata index memory
-rw-r--r-- | src/H5Fint.c | 20 | ||||
-rw-r--r-- | src/H5Fvfd_swmr.c | 2 | ||||
-rw-r--r-- | test/vfd_swmr_reader.c | 14 |
3 files changed, 24 insertions, 12 deletions
diff --git a/src/H5Fint.c b/src/H5Fint.c index 0531223..e3040d4 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -1425,15 +1425,23 @@ H5F__dest(H5F_t *f, hbool_t flush) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") - /* A VFD SWMR reader may still have a metadata index at this stage. - * If so, free it. + /* A VFD SWMR reader may still have metadata indexes at this stage. + * If so, free them. */ - if (f->shared->vfd_swmr && f->shared->mdf_idx != NULL) { - HDfree(f->shared->mdf_idx); - f->shared->mdf_idx = NULL; - f->shared->mdf_idx_len = 0; + if (f->shared->vfd_swmr) { + if (f->shared->mdf_idx != NULL) { + H5MM_xfree(f->shared->mdf_idx); + f->shared->mdf_idx = NULL; + f->shared->mdf_idx_len = 0; + } + if (f->shared->old_mdf_idx != NULL) { + H5MM_xfree(f->shared->old_mdf_idx); + f->shared->old_mdf_idx = NULL; + f->shared->old_mdf_idx_len = 0; + } } + /* Free mount table */ f->shared->mtab.child = (H5F_mount_t *)H5MM_xfree(f->shared->mtab.child); f->shared->mtab.nalloc = 0; diff --git a/src/H5Fvfd_swmr.c b/src/H5Fvfd_swmr.c index dbe04ec..555619d 100644 --- a/src/H5Fvfd_swmr.c +++ b/src/H5Fvfd_swmr.c @@ -1923,7 +1923,7 @@ H5F__vfd_swmr_create_index(H5F_shared_t *shared) HDassert(entries_in_index > 0); - index = HDcalloc(entries_in_index, sizeof(index[0])); + index = H5MM_calloc(entries_in_index * sizeof(index[0])); if (index == NULL) { HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, diff --git a/test/vfd_swmr_reader.c b/test/vfd_swmr_reader.c index ff31bdd..5f61102 100644 --- a/test/vfd_swmr_reader.c +++ b/test/vfd_swmr_reader.c @@ -88,8 +88,8 @@ check_dataset(hid_t fid, hbool_t verbose, FILE *verbose_file, int fill_count = 0; /* # of times fill value (0) was read * instead of the expected value. */ - hid_t dsid; /* Dataset ID */ - hid_t file_sid; /* Dataset's space ID */ + hid_t dsid = H5I_INVALID_HID; /* Dataset ID */ + hid_t file_sid = H5I_INVALID_HID; /* Dataset's space ID */ hssize_t snpoints; /* Number of elements in dataset */ hsize_t start[2] = {0, 0}, count[2] = {1, 1}; /* Hyperslab selection values */ @@ -237,9 +237,9 @@ read_records(const char *filename, hbool_t verbose, FILE *verbose_file, time_t curr_time; /* Current time */ symbol_info_t **sym_com = NULL; /* Pointers to array of common dataset IDs */ symbol_info_t **sym_rand = NULL; /* Pointers to array of random dataset IDs */ - hid_t mem_sid; /* Memory dataspace ID */ - hid_t fid; /* SWMR test file ID */ - hid_t fapl; /* file access property list */ + hid_t mem_sid = H5I_INVALID_HID; /* Memory dataspace ID */ + hid_t fid = H5I_INVALID_HID; /* SWMR test file ID */ + hid_t fapl = H5I_INVALID_HID; /* file access property list */ symbol_t record; /* The record to read from the dataset */ unsigned v; /* Local index variable */ hbool_t use_log_vfd = FALSE; /* Use the log VFD (set this manually) */ @@ -672,6 +672,10 @@ int main(int argc, const char *argv[]) HDexit(1); } /* end if */ + /* Close the output file */ + if(verbose) + HDfclose(verbose_file); + return 0; } |