diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2001-01-03 18:33:56 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2001-01-03 18:33:56 (GMT) |
commit | cf4ff99bdfa213a17e666a587a27b0314ac353c0 (patch) | |
tree | 3f953ff7335d641eefc109334bb76cfb1a19bc47 | |
parent | c3be99abb19940db24fb3f5ff5fb1a5e78f832e6 (diff) | |
download | hdf5-cf4ff99bdfa213a17e666a587a27b0314ac353c0.zip hdf5-cf4ff99bdfa213a17e666a587a27b0314ac353c0.tar.gz hdf5-cf4ff99bdfa213a17e666a587a27b0314ac353c0.tar.bz2 |
[svn-r3229] Purpose:
Bug fix
Description:
Close several potential resource leaks in failure conditions.
Platforms tested:
FreeBSD 4.2 (hawkwind)
-rw-r--r-- | tools/h5tools.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tools/h5tools.c b/tools/h5tools.c index 125c87f..4f92a17 100644 --- a/tools/h5tools.c +++ b/tools/h5tools.c @@ -1508,8 +1508,10 @@ h5dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, else p_nelmts = 1; - if (p_nelmts == 0) + if (p_nelmts == 0) { + H5Sclose(f_space); return 0; /*nothing to print*/ + } ctx.size_last_dim = total_size[ctx.ndims - 1]; @@ -1560,8 +1562,12 @@ h5dump_simple_dset(FILE *stream, const h5dump_t *info, hid_t dset, } /* Read the data */ - if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) + if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) { + H5Sclose(f_space); + H5Sclose(sm_space); + free(sm_buf); return -1; + } /* Print the data */ flags = (elmtno == 0) ? START_OF_DATA : 0; @@ -2461,7 +2467,7 @@ h5dump_fopen(const char *fname, char *drivername, size_t drivername_size) hid_t fapl; } driver[16]; static int ndrivers = 0; - hid_t fid, fapl = H5P_DEFAULT; + hid_t fid=(-1), fapl = H5P_DEFAULT; int drivernum; if (!ndrivers) { |