Skip to content

Commit

Permalink
Add 1 to string length in calls to H5Tset_size(); the length should i…
Browse files Browse the repository at this point in the history
…nclude the trailing null
  • Loading branch information
MarkRivers committed Sep 22, 2020
1 parent 9321f2a commit bfa3151
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ADApp/pluginSrc/NDFileHDF5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ hid_t NDFileHDF5::writeH5dsetStr(hid_t element, const std::string &name, const s

hdfdataspace = H5Screate_simple(rank, &dims, NULL);
hdfdatatype = H5Tcopy(H5T_C_S1);
hdfstatus = H5Tset_size(hdfdatatype, str_value.size());
hdfstatus = H5Tset_size(hdfdatatype, str_value.size()+1);
hdfstatus = H5Tset_strpad(hdfdatatype, H5T_STR_NULLTERM);
hdfdset = H5Dcreate2(element, name.c_str(), hdfdatatype, hdfdataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
if (hdfdset < 0) {
Expand Down Expand Up @@ -1084,7 +1084,7 @@ void NDFileHDF5::writeH5attrStr(hid_t element, const std::string &attr_name, con

hdfattrdataspace = H5Screate(H5S_SCALAR);
hdfdatatype = H5Tcopy(H5T_C_S1);
hdfstatus = H5Tset_size(hdfdatatype, str_attr_value.size());
hdfstatus = H5Tset_size(hdfdatatype, str_attr_value.size()+1);
hdfstatus = H5Tset_strpad(hdfdatatype, H5T_STR_NULLTERM);
hdfattr = H5Acreate2(element, attr_name.c_str(), hdfdatatype, hdfattrdataspace, H5P_DEFAULT, H5P_DEFAULT);
if (hdfattr < 0) {
Expand Down Expand Up @@ -3017,7 +3017,7 @@ asynStatus NDFileHDF5::writeStringAttribute(hid_t element, const char * attrName
if (strlen(attrStrValue) > 0){
hdfattrdataspace = H5Screate(H5S_SCALAR);
hdfdatatype = H5Tcopy(H5T_C_S1);
H5Tset_size(hdfdatatype, strlen(attrStrValue));
H5Tset_size(hdfdatatype, strlen(attrStrValue)+1);
H5Tset_strpad(hdfdatatype, H5T_STR_NULLTERM);
hdfattr = H5Acreate2(element, attrName,
hdfdatatype, hdfattrdataspace,
Expand Down

0 comments on commit bfa3151

Please sign in to comment.