mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-09 08:11:38 +08:00
Merge pull request #1564 from NetCDF-World-Domination-Council/ejh_docs_cleanup
fix memory issue that may occur for some HDF5 file opens
This commit is contained in:
commit
29d070c50f
@ -2532,6 +2532,10 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
|
||||
/* Get HDF5-specific group info. */
|
||||
hdf5_grp = (NC_HDF5_GRP_INFO_T *)grp->format_grp_info;
|
||||
|
||||
/* Set user data for iteration over any child groups. */
|
||||
udata.grp = grp;
|
||||
udata.grps = nclistnew();
|
||||
|
||||
/* Open this HDF5 group and retain its grpid. It will remain open
|
||||
* with HDF5 until this file is nc_closed. */
|
||||
if (!hdf5_grp->hdf_grpid)
|
||||
@ -2579,10 +2583,6 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
|
||||
iter_index = H5_INDEX_NAME;
|
||||
}
|
||||
|
||||
/* Set user data for iteration over any child groups. */
|
||||
udata.grp = grp;
|
||||
udata.grps = nclistnew();
|
||||
|
||||
/* Iterate over links in this group, building lists for the types,
|
||||
* datasets and groups encountered. A pointer to udata will be
|
||||
* passed as a parameter to the callback function
|
||||
|
@ -1,8 +1,10 @@
|
||||
/* This is part of the netCDF package. Copyright 2005-2018, University
|
||||
Corporation for Atmospheric Research/Unidata. See COPYRIGHT file
|
||||
/* This is part of the netCDF package. Copyright 2005-2019, University
|
||||
Corporation for Atmospheric Research/Unidata. See COPYRIGHT file
|
||||
for conditions of use.
|
||||
|
||||
Test that HDF5 and NetCDF-4 can read and write the same file.
|
||||
|
||||
Ed Hartnett
|
||||
*/
|
||||
#include <config.h>
|
||||
#include <nc_tests.h>
|
||||
@ -253,5 +255,24 @@ main(int argc, char **argv)
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
#endif /* USE_SZIP */
|
||||
/* This test suggested by user brentd42 to find a memory problem in
|
||||
* function rec_read_metadata(). This test demonstrates the bug on
|
||||
* address sanitizer runs. See
|
||||
* https://github.com/Unidata/netcdf-c/issues/1558. */
|
||||
printf("*** testing error when opening HDF5 file without creating ordering...");
|
||||
{
|
||||
hid_t file_hid;
|
||||
int ncid;
|
||||
char *filename = "tst_interops5.h5";
|
||||
|
||||
/* Create a HDF5 file, but don't set creation ordering on. */
|
||||
file_hid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
||||
H5Fclose(file_hid);
|
||||
|
||||
/* Open the file with netCDF. */
|
||||
nc_set_log_level(3);
|
||||
if (nc_open(filename, NC_WRITE, &ncid) != NC_ECANTWRITE) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
FINAL_RESULTS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user