diff options
author | Thomas White <taw@physics.org> | 2023-07-26 14:45:02 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2023-07-26 14:48:05 +0200 |
commit | 4038a12faab1ac3ef3e5c6aacd8850a58d8b9b2d (patch) | |
tree | 2b35298d8a28ebea757328ef79d015596653f646 /libcrystfel/src/image-hdf5.c | |
parent | dea9ccdb72a0f715401a21907c1004de69fbabf1 (diff) |
Fix memory leaks in header caching
Diffstat (limited to 'libcrystfel/src/image-hdf5.c')
-rw-r--r-- | libcrystfel/src/image-hdf5.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libcrystfel/src/image-hdf5.c b/libcrystfel/src/image-hdf5.c index a915eb0e..c34dfc7b 100644 --- a/libcrystfel/src/image-hdf5.c +++ b/libcrystfel/src/image-hdf5.c @@ -802,6 +802,7 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name) dh = H5Dopen2(fh, subst_name, H5P_DEFAULT); if ( dh < 0 ) { ERROR("No such numeric field '%s'\n", subst_name); + free(subst_name); close_hdf5(fh); return 1; } @@ -821,6 +822,7 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name) ERROR("HDF5 header is not a recognised type (%s).\n", subst_name); close_hdf5(fh); + free(subst_name); return 1; } @@ -831,6 +833,7 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name) if ( ndims > 64 ) { ERROR("Too many dimensions for numeric value\n"); close_hdf5(fh); + free(subst_name); return 1; } H5Sget_simple_extent_dims(sh, size, NULL); @@ -857,6 +860,7 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name) return 1; } image_cache_header_float(image, name, val); + free(subst_name); return 0; } else if ( class == H5T_INTEGER ) { @@ -872,6 +876,7 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name) return 1; } image_cache_header_int(image, name, val); + free(subst_name); return 0; } else if ( class == H5T_STRING ) { @@ -912,6 +917,7 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name) } else { /* Should never be reached */ ERROR("Invalid HDF5 class %i\n", class); + free(subst_name); return 1; } } @@ -920,6 +926,7 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name) if ( dim_vals == NULL ) { ERROR("Couldn't parse event '%s'\n"); close_hdf5(fh); + free(subst_name); return 1; } @@ -928,6 +935,7 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name) if ( (f_offset == NULL) || (f_count == NULL) ) { ERROR("Couldn't allocate dimension arrays\n"); close_hdf5(fh); + free(subst_name); return 1; } @@ -945,6 +953,7 @@ int image_hdf5_read_header_to_cache(struct image *image, const char *name) subst_name, i, dim_vals[dim_val_pos], size[i]); close_hdf5(fh); + free(subst_name); return 1; } |