[MOAB-dev] r2150 - MOAB/trunk

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Wed Oct 15 13:21:32 CDT 2008


Author: kraftche
Date: 2008-10-15 13:21:32 -0500 (Wed, 15 Oct 2008)
New Revision: 2150

Modified:
   MOAB/trunk/WriteHDF5.cpp
Log:
Fix bug in HDF5 writer:  Explicity handle case where no handle in the 
  contents of an entity set is being written to the file (e.g. all stale 
  handles).  Avoids subtract of 1 from 0u, which resulted in indexing (way) 
  past the end of an array.


Modified: MOAB/trunk/WriteHDF5.cpp
===================================================================
--- MOAB/trunk/WriteHDF5.cpp	2008-10-15 17:22:30 UTC (rev 2149)
+++ MOAB/trunk/WriteHDF5.cpp	2008-10-15 18:21:32 UTC (rev 2150)
@@ -1108,8 +1108,15 @@
     }
   }
   
-    // if we ran out of space, just do list format
-  if (output_id_list.end() - i < 2) {
+    // if we aren't writing anything (no entities in MBRange are
+    // being written to to file), clean up and return
+  if (i == output_id_list.begin()) {
+    output_id_list.clear();
+    return MB_SUCCESS;
+  }
+  
+    // if we ran out of space, (or set is empty) just do list format
+  if (output_id_list.end() - i < 2 || i == output_id_list.begin()) {
     range_to_id_list( input_range, &output_id_list[0] );
     output_id_list.erase( std::remove( output_id_list.begin(), 
                                        output_id_list.end(), 
@@ -2239,7 +2246,8 @@
       rval = range_to_blocked_list( set_contents, set_contents_ids );
       CHK_MB_ERR_0(rval);
       
-      if (set_contents_ids.size() < (unsigned long)contents_length_set)
+      if (set_contents_ids.size() < (unsigned long)contents_length_set
+          && !set_contents_ids.empty())
       {
         contents_length_set = set_contents_ids.size();
         compressed_sets.insert( *iter );




More information about the moab-dev mailing list