summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2010-05-06 17:00:29 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2010-05-06 17:00:29 (GMT)
commite87f3dd558a96c6ebedd03a8ac8acb91cb5e1be8 (patch)
tree1d58ef08d09b44cff4ae7a20355412e2eaad8d90
parentabd749619d15cf7a3e927232ac2ad7ed1c726dd2 (diff)
downloadhdf5-e87f3dd558a96c6ebedd03a8ac8acb91cb5e1be8.zip
hdf5-e87f3dd558a96c6ebedd03a8ac8acb91cb5e1be8.tar.gz
hdf5-e87f3dd558a96c6ebedd03a8ac8acb91cb5e1be8.tar.bz2
[svn-r18728] Purpose: Fixed bug# 1719
Description: Closed a temporarily opened datatype to clean up memory leak, in getTypeClass. Platforms tested: Linux/32 2.6 (jam) FreeBSD/64 6.3 (liberty) SunOS 5.10 (linew)
-rw-r--r--c++/src/H5AbstractDs.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp
index 19eeb33..9cf1ee8 100644
--- a/c++/src/H5AbstractDs.cpp
+++ b/c++/src/H5AbstractDs.cpp
@@ -81,15 +81,26 @@ H5T_class_t AbstractDs::getTypeClass() const
// Gets the class of the datatype and validate it before returning
H5T_class_t type_class = H5Tget_class(datatype_id);
- if( type_class != H5T_NO_CLASS )
- return( type_class );
- else
+
+ // Close temporary datatype_id
+ herr_t ret_value = H5Tclose(datatype_id);
+ if (ret_value < 0)
+ {
+ if (fromClass() == "DataSet")
+ throw DataTypeIException("DataSet::getTypeClass", "H5Tclose failed");
+ else if (fromClass() == "Attribute")
+ throw DataTypeIException("Attribute::getTypeClass", "H5Tclose failed");
+ }
+
+ // Check on the returned type_class
+ if (type_class == H5T_NO_CLASS)
{
if (fromClass() == "DataSet")
throw DataTypeIException("DataSet::getTypeClass", "H5Tget_class returns H5T_NO_CLASS");
else if (fromClass() == "Attribute")
throw DataTypeIException("Attribute::getTypeClass", "H5Tget_class returns H5T_NO_CLASS");
}
+ return(type_class);
}
//--------------------------------------------------------------------------