summaryrefslogtreecommitdiffstats
path: root/c++/src/H5CommonFG.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2014-10-01 04:05:57 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2014-10-01 04:05:57 (GMT)
commit22d0d32716a588063970a7e412d69a2937118034 (patch)
tree5e4511f0606a402590f3a27ea793006cf4db274e /c++/src/H5CommonFG.cpp
parent10f1e6acf8916a429f2cc925f49518cfc0015b6c (diff)
downloadhdf5-22d0d32716a588063970a7e412d69a2937118034.zip
hdf5-22d0d32716a588063970a7e412d69a2937118034.tar.gz
hdf5-22d0d32716a588063970a7e412d69a2937118034.tar.bz2
[svn-r25644] Purpose: Fixed HDFFV-8928
Description: Followed hints on the JIRA issue to remove several potential memory leaks. Platforms tested: Linux/ppc64 (ostrich) Linux/32 2.6 (jam) SunOS 5.11 (emu)
Diffstat (limited to 'c++/src/H5CommonFG.cpp')
-rw-r--r--c++/src/H5CommonFG.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index 8ee88d6..3aa0386 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -443,7 +443,10 @@ H5std_string CommonFG::getLinkval( const char* name, size_t size ) const
ret_value = H5Lget_val(getLocId(), name, value_C, val_size, H5P_DEFAULT);
if( ret_value < 0 )
+ {
+ delete []value_C;
throwException("getLinkval", "H5Lget_val failed");
+ }
value = H5std_string(value_C);
delete []value_C;
@@ -916,6 +919,12 @@ H5std_string CommonFG::getObjnameByIdx(hsize_t idx) const
name_len = H5Lget_name_by_idx(getLocId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, name_len+1, H5P_DEFAULT);
+ if (name_len < 0)
+ {
+ delete []name_C;
+ throwException("getObjnameByIdx", "H5Lget_name_by_idx failed");
+ }
+
// clean up and return the string
H5std_string name = H5std_string(name_C);
delete []name_C;
@@ -960,10 +969,15 @@ ssize_t CommonFG::getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size)
char* name_C = new char[size+1]; // temporary C-string for object name
HDmemset(name_C, 0, size+1); // clear buffer
+ // call overloaded function to get the name
ssize_t name_len = getObjnameByIdx(idx, name_C, size+1);
if(name_len < 0)
+ {
+ delete []name_C;
throwException("getObjnameByIdx", "H5Lget_name_by_idx failed");
+ }
+ // clean up and return the string
name = H5std_string(name_C);
delete []name_C;
return (name_len);