From 9aab5e7033a9015d7d34de353642a8f61f530b86 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 14 Jul 2015 13:32:57 +0200 Subject: Fix HDF5 memory leaks --- libcrystfel/src/hdf5-file.c | 14 +++++++++----- 1 file 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