summaryrefslogtreecommitdiffstats
path: root/c++/src/H5Attribute.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2010-04-27 20:19:20 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2010-04-27 20:19:20 (GMT)
commita0911ce3de9a658076ef0c115f38bb6ba131a9ef (patch)
treeef9da016cf667a07f6b02b955c2dead8f7d7fb9d /c++/src/H5Attribute.cpp
parent97f4486769962315a8229f16485cd3740b8d22c5 (diff)
downloadhdf5-a0911ce3de9a658076ef0c115f38bb6ba131a9ef.zip
hdf5-a0911ce3de9a658076ef0c115f38bb6ba131a9ef.tar.gz
hdf5-a0911ce3de9a658076ef0c115f38bb6ba131a9ef.tar.bz2
[svn-r18640] Description:
Added a null character to terminate a fixed-length string returned by H5Aread. Platforms tested: Linux/32 2.6 (jam) FreeBSD/64 6.3 (liberty)
Diffstat (limited to 'c++/src/H5Attribute.cpp')
-rw-r--r--c++/src/H5Attribute.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index 5f04865..a2445d6 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -423,18 +423,15 @@ void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) c
// If there is data, allocate buffer and read it.
if (attr_size > 0)
{
- char *strg_C = NULL;
-
- strg_C = new char [(size_t)attr_size+1];
+ char *strg_C = new char[(size_t)attr_size+1];
herr_t ret_value = H5Aread(id, mem_type.getId(), strg_C);
-
if( ret_value < 0 )
{
delete []strg_C; // de-allocate for fixed-len string
throw AttributeIException("Attribute::read", "H5Aread failed");
}
-
// Get string from the C char* and release resource allocated locally
+ strg_C[attr_size] = '\0';
strg = strg_C;
delete []strg_C;
}