diff options
author | Thomas White <taw@physics.org> | 2015-07-14 13:32:57 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2015-07-14 13:32:57 +0200 |
commit | 9aab5e7033a9015d7d34de353642a8f61f530b86 (patch) | |
tree | 9eb73702699b0317fe8088d84861a087a610d174 /libcrystfel/src/hdf5-file.c | |
parent | 7c473f3cccab29c4581c97d41770e4aa3c67eab3 (diff) |
Fix HDF5 memory leaks
Diffstat (limited to 'libcrystfel/src/hdf5-file.c')
-rw-r--r-- | libcrystfel/src/hdf5-file.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c index c58a3ae5..fc4b1355 100644 --- a/libcrystfel/src/hdf5-file.c +++ b/libcrystfel/src/hdf5-file.c @@ -1741,10 +1741,12 @@ static int looks_like_image(hid_t h) if ( sh < 0 ) return 0; if ( H5Sget_simple_extent_ndims(sh) != 2 ) { + H5Sclose(sh); return 0; } H5Sget_simple_extent_dims(sh, size, max_size); + H5Sclose(sh); if ( ( size[0] > 64 ) && ( size[1] > 64 ) ) return 1; @@ -1779,6 +1781,7 @@ int hdfile_is_scalar(struct hdfile *f, const char *name, int verbose) if ( verbose ) { ERROR("Too many dimensions (%i).\n", ndims); } + H5Sclose(sh); H5Tclose(type); H5Dclose(dh); return 0; @@ -1786,6 +1789,9 @@ int hdfile_is_scalar(struct hdfile *f, const char *name, int verbose) /* Check that the size in all dimensions is 1 */ H5Sget_simple_extent_dims(sh, size, NULL); + H5Sclose(sh); + H5Tclose(type); + H5Dclose(dh); for ( i=0; i<ndims; i++ ) { if ( size[i] != 1 ) { if ( verbose ) { @@ -1793,15 +1799,10 @@ int hdfile_is_scalar(struct hdfile *f, const char *name, int verbose) "size[%i]=%i)\n", name, ndims, i, (int)size[i]); } - H5Tclose(type); - H5Dclose(dh); return 0; } } - H5Tclose(type); - H5Dclose(dh); - return 1; } @@ -1952,6 +1953,9 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name, tmp[size] = '\0'; chomp(tmp); } + + H5Sclose(sh); + } else { int r; |