File tree Expand file tree Collapse file tree 2 files changed +27
-6
lines changed
Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -2532,6 +2532,10 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
25322532 /* Get HDF5-specific group info. */
25332533 hdf5_grp = (NC_HDF5_GRP_INFO_T * )grp -> format_grp_info ;
25342534
2535+ /* Set user data for iteration over any child groups. */
2536+ udata .grp = grp ;
2537+ udata .grps = nclistnew ();
2538+
25352539 /* Open this HDF5 group and retain its grpid. It will remain open
25362540 * with HDF5 until this file is nc_closed. */
25372541 if (!hdf5_grp -> hdf_grpid )
@@ -2579,10 +2583,6 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
25792583 iter_index = H5_INDEX_NAME ;
25802584 }
25812585
2582- /* Set user data for iteration over any child groups. */
2583- udata .grp = grp ;
2584- udata .grps = nclistnew ();
2585-
25862586 /* Iterate over links in this group, building lists for the types,
25872587 * datasets and groups encountered. A pointer to udata will be
25882588 * passed as a parameter to the callback function
Original file line number Diff line number Diff line change 1- /* This is part of the netCDF package. Copyright 2005-2018 , University
2- Corporation for Atmospheric Research/Unidata. See COPYRIGHT file
1+ /* This is part of the netCDF package. Copyright 2005-2019 , University
2+ Corporation for Atmospheric Research/Unidata. See COPYRIGHT file
33 for conditions of use.
44
55 Test that HDF5 and NetCDF-4 can read and write the same file.
6+
7+ Ed Hartnett
68*/
79#include <config.h>
810#include <nc_tests.h>
@@ -253,5 +255,24 @@ main(int argc, char **argv)
253255 }
254256 SUMMARIZE_ERR ;
255257#endif /* USE_SZIP */
258+ /* This test suggested by user brentd42 to find a memory problem in
259+ * function rec_read_metadata(). This test demonstrates the bug on
260+ * address sanitizer runs. See
261+ * https://github.com/Unidata/netcdf-c/issues/1558. */
262+ printf ("*** testing error when opening HDF5 file without creating ordering..." );
263+ {
264+ hid_t file_hid ;
265+ int ncid ;
266+ char * filename = "tst_interops5.h5" ;
267+
268+ /* Create a HDF5 file, but don't set creation ordering on. */
269+ file_hid = H5Fcreate (filename , H5F_ACC_TRUNC , H5P_DEFAULT , H5P_DEFAULT );
270+ H5Fclose (file_hid );
271+
272+ /* Open the file with netCDF. */
273+ nc_set_log_level (3 );
274+ if (nc_open (filename , NC_WRITE , & ncid ) != NC_ECANTWRITE ) ERR ;
275+ }
276+ SUMMARIZE_ERR ;
256277 FINAL_RESULTS ;
257278}
You can’t perform that action at this time.
0 commit comments