diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-10-02 04:32:16 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2014-10-02 04:32:16 (GMT) |
commit | eb20ea5379968148df2035cbebdcf3311f214717 (patch) | |
tree | 8d2752e91e039088c6e2dab032c39e60ba39d09d /c++/src/H5CommonFG.cpp | |
parent | 9c9326c7debc3b4f32602ec21cc67cfccafa6fc0 (diff) | |
download | hdf5-eb20ea5379968148df2035cbebdcf3311f214717.zip hdf5-eb20ea5379968148df2035cbebdcf3311f214717.tar.gz hdf5-eb20ea5379968148df2035cbebdcf3311f214717.tar.bz2 |
[svn-r25655] Purpose: Fixed HDFFV-8928
Description:
Followed hints from user's report on JIRA 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.cpp | 14 |
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); |