summaryrefslogtreecommitdiffstats
path: root/c++/src/H5Location.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2014-03-22 20:39:44 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2014-03-22 20:39:44 (GMT)
commit67be45610fd450909038afea54f79e6a91c458cf (patch)
tree374bb6c2c7e968e2bf8756c52eb2eb20f0a61612 /c++/src/H5Location.cpp
parent958a762dd16bac9a1c5a7a2c594adce6758f81f4 (diff)
downloadhdf5-67be45610fd450909038afea54f79e6a91c458cf.zip
hdf5-67be45610fd450909038afea54f79e6a91c458cf.tar.gz
hdf5-67be45610fd450909038afea54f79e6a91c458cf.tar.bz2
[svn-r24867] Description:
- Added a null terminator to the comment returned from the C call, in getComment methods - Some minor cleanup Platforms tested: Linux/ppc64 (ostrich) Linux/32 2.6 (jam) Linux/64 2.6 (platypus)/PGI compilers
Diffstat (limited to 'c++/src/H5Location.cpp')
-rw-r--r--c++/src/H5Location.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp
index fdbfd61..3240f70 100644
--- a/c++/src/H5Location.cpp
+++ b/c++/src/H5Location.cpp
@@ -500,8 +500,12 @@ ssize_t H5Location::getComment(const char* name, const size_t buf_size, char* co
{
throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed");
}
+ // If the comment is longer than the provided buffer size, the C library
+ // will not null terminate it
+ if (comment_len >= buf_size)
+ comment[buf_size-1] = '\0';
- // Return the comment length, which might be different from buf_size
+ // Return the actual comment length, which might be different from buf_size
return(comment_len);
}
@@ -544,7 +548,7 @@ H5std_string H5Location::getComment(const char* name, const size_t buf_size) con
HDmemset(comment_C, 0, tmp_len+1); // clear buffer
// Used overloaded function
- ssize_t comment_len = getComment(name, tmp_len, comment_C);
+ ssize_t comment_len = getComment(name, tmp_len+1, comment_C);
// Convert the C comment to return
comment = comment_C;