From db55b9f2b589d07d5abb696a62fe5db57516ae26 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Tue, 16 Jul 2019 17:09:05 +0200 Subject: hdfile_get_string_value(): Detect non-scalar string Handling strings in HDF5 is already a complete pain. Eventually we should handle an array of strings, but it's too hard for now. --- libcrystfel/src/hdf5-file.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libcrystfel') diff --git a/libcrystfel/src/hdf5-file.c b/libcrystfel/src/hdf5-file.c index 33ae123b..8451c68a 100644 --- a/libcrystfel/src/hdf5-file.c +++ b/libcrystfel/src/hdf5-file.c @@ -2094,8 +2094,14 @@ char *hdfile_get_string_value(struct hdfile *f, const char *name, size = H5Tget_size(type); tmp = malloc(size+1); - sh = H5Screate(H5S_SCALAR); + sh = H5Dget_space(dh); + if ( H5Sget_simple_extent_ndims(sh) ) { + H5Tclose(type); + free(subst_name); + return strdup("[non-scalar string]"); + } + sh = H5Screate(H5S_SCALAR); r = H5Dread(dh, type, sh, H5S_ALL, H5P_DEFAULT, tmp); H5Sclose(sh); if ( r < 0 ) { -- cgit v1.2.3