summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2016-12-07 20:30:48 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2016-12-07 20:30:48 (GMT)
commit4977ff4c762ed7b1ef9f0d6754339489871cd5c6 (patch)
tree8ee3cce85f119162b0b00b28c96b2b1cae13138c
parentc2c10a6f191c0d27d638e6866c5c736ce3b219b8 (diff)
parent0f2f51bb7bdac91ba670bd810bab687594a60251 (diff)
downloadhdf5-4977ff4c762ed7b1ef9f0d6754339489871cd5c6.zip
hdf5-4977ff4c762ed7b1ef9f0d6754339489871cd5c6.tar.gz
hdf5-4977ff4c762ed7b1ef9f0d6754339489871cd5c6.tar.bz2
Merge pull request #189 in HDFFV/hdf5 from ~DEROBINS/hdf5_der:more_valgrind to develop
Fixed valgrind issues in H5F_open() exposed by swmr.c. * commit '0f2f51bb7bdac91ba670bd810bab687594a60251': Updated the comment for the valgrind fix. Fixed a valgrind problem in file shutdown exposed by the swmr.c test.
-rw-r--r--src/H5Fint.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/H5Fint.c b/src/H5Fint.c
index 363812d..fd79dc2 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -1185,8 +1185,15 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
} /* end if */
/* Create the 'top' file structure */
- if(NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf)))
+ if(NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf))) {
+ /* If this is the only time the file has been opened and the struct
+ * returned is NULL, H5FD_close() will never be called via H5F_dest()
+ * so we have to close lf here before heading to the error handling.
+ */
+ if(H5FD_close(lf) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to close low-level file info")
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to initialize file structure")
+ } /* end if */
/* Need to set status_flags in the superblock if the driver has a 'lock' method */
if(drvr->lock)
@@ -1342,10 +1349,9 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id,
ret_value = file;
done:
- if(!ret_value && file)
+ if((NULL == ret_value) && file)
if(H5F_dest(file, dxpl_id, FALSE) < 0)
HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file")
-
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_open() */