Coverity Fixes: CID #1097683 #1097684 74/19174/6
Siddhartha Gairola [Sat, 11 Mar 2017 21:01:43 +0000 (02:01 +0530)]
Change-Id: I89d76beb300f947b834fd5d7f31b707fc01fc464

scilab/modules/hdf5/src/cpp/H5Dataset.cpp
scilab/modules/hdf5/src/cpp/H5Object.cpp

index a0f6628..63efd64 100644 (file)
@@ -43,9 +43,15 @@ H5Dataset::H5Dataset(H5Object & _parent, hid_t _dataset, const std::string & _na
 
 H5Dataset::~H5Dataset()
 {
+    herr_t status;
+
     if (dataset >= 0)
     {
-        H5Dclose(dataset);
+        status = H5Dclose(dataset);
+        if (status < 0)
+        {
+            throw H5Exception(__LINE__, __FILE__, _("Cannot close the dataset named %s."), name.c_str());
+        }
     }
 }
 
index 2c1b9ee..7747427 100644 (file)
@@ -403,9 +403,14 @@ std::string H5Object::getCompletePath() const
 void H5Object::getLinksInfo(const H5Object & obj, std::vector<std::string> & linksName, std::vector<std::string> & type, std::vector<std::string> & linksType)
 {
     hsize_t idx = 0;
+    herr_t err;
     LinksInfo info(&linksName, &type, &linksType);
 
-    H5Literate(obj.getH5Id(), H5_INDEX_NAME, H5_ITER_INC, &idx, iterateGetInfo, &info);
+    err = H5Literate(obj.getH5Id(), H5_INDEX_NAME, H5_ITER_INC, &idx, iterateGetInfo, &info);
+    if(err < 0)
+    {
+        throw H5Exception(__LINE__, __FILE__, _("Cannot list group contents"));
+    }
 }
 
 herr_t H5Object::iterateGetInfo(hid_t g_id, const char * name, const H5L_info_t * info, void * op_data)