diff options
author | Thomas White <taw@physics.org> | 2019-07-16 17:09:05 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-07-16 17:09:05 +0200 |
commit | db55b9f2b589d07d5abb696a62fe5db57516ae26 (patch) | |
tree | b928d51ff995630e0e364278510939f63e1590ac /libcrystfel/src/hdf5-file.c | |
parent | 1af8fa298dec785f8934d203f461f983ae8d42e3 (diff) |
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.
Diffstat (limited to 'libcrystfel/src/hdf5-file.c')
-rw-r--r-- | libcrystfel/src/hdf5-file.c | 8 |
1 files changed, 7 insertions, 1 deletions
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 ) { |