From 7999bc23a572152e7c6778dd7f532ac3aa115761 Mon Sep 17 00:00:00 2001 From: tradke Date: Wed, 7 Jan 2004 17:04:26 +0000 Subject: Need to explicitely set the terminating NUL character when reading in a string attribute. git-svn-id: http://svn.cactuscode.org/arrangements/CactusExternal/FlexIO/trunk@52 21a6bef8-4479-4f54-8f8d-0db94a2919ef --- src/H5IO.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/H5IO.cc b/src/H5IO.cc index d5d8795..d52ac2b 100644 --- a/src/H5IO.cc +++ b/src/H5IO.cc @@ -629,6 +629,12 @@ int H5IO::readAttribute(int number,void *data){ hid_t attrib = H5Aopen_idx(dataset,number); hid_t atype = H5Aget_type(attrib); H5Aread(attrib,atype /*DataType2H5(H5DataType2DataType(atype))*/ ,data); + // need to explicitely set the terminating NUL character in string attributes + if (H5Tget_class (atype) == H5T_STRING) + { + size_t len = H5Tget_size (atype); + ((char *) data)[len] = 0; + } H5Tclose(atype); H5Aclose(attrib); return 1; -- cgit v1.2.3