[MOAB-dev] r1644 - MOAB/trunk

kraftche at mcs.anl.gov kraftche at mcs.anl.gov
Wed Mar 12 14:49:57 CDT 2008


Author: kraftche
Date: 2008-03-12 14:49:57 -0500 (Wed, 12 Mar 2008)
New Revision: 1644

Modified:
   MOAB/trunk/MBReadUtil.cpp
   MOAB/trunk/TypeSequenceManager.cpp
Log:
add checks for invalid size for sequence creation

Modified: MOAB/trunk/MBReadUtil.cpp
===================================================================
--- MOAB/trunk/MBReadUtil.cpp	2008-03-12 18:45:10 UTC (rev 1643)
+++ MOAB/trunk/MBReadUtil.cpp	2008-03-12 19:49:57 UTC (rev 1644)
@@ -50,6 +50,12 @@
 
   MBErrorCode error;
   EntitySequence* seq = 0;
+  
+  if (num_nodes < 1) {
+    actual_start_handle = 0;
+    arrays.clear();
+    return MB_INDEX_OUT_OF_RANGE;
+  }
 
   // create an entity sequence for these nodes 
   error = mMB->sequence_manager()->create_entity_sequence(
@@ -88,6 +94,12 @@
   MBErrorCode error;
   EntitySequence* seq;
   
+  if (num_elements < 1) {
+    actual_start_handle = 0;
+    array = 0;
+    return MB_INDEX_OUT_OF_RANGE;
+  }
+  
 //  if (mdb_type <= MBVERTEX || mdb_type >= MBPOLYHEDRON || mdb_type == MBPOLYGON)
 //    return MB_TYPE_OUT_OF_RANGE;
 
@@ -121,6 +133,11 @@
                                             int proc,
                                             MBEntityHandle& start_handle )
 {
+  if (num_sets < 1) {
+    start_handle = 0;
+    return MB_INDEX_OUT_OF_RANGE;
+  }
+
   MBErrorCode error;
   EntitySequence* seq;
   error = mMB->sequence_manager()->create_meshset_sequence( num_sets,

Modified: MOAB/trunk/TypeSequenceManager.cpp
===================================================================
--- MOAB/trunk/TypeSequenceManager.cpp	2008-03-12 18:45:10 UTC (rev 1643)
+++ MOAB/trunk/TypeSequenceManager.cpp	2008-03-12 19:49:57 UTC (rev 1644)
@@ -89,7 +89,8 @@
     return MB_FAILURE;
 
   if (seq_ptr->data()->start_handle() > seq_ptr->start_handle() ||
-      seq_ptr->data()->end_handle() < seq_ptr->end_handle())
+      seq_ptr->data()->end_handle() < seq_ptr->end_handle() ||
+      seq_ptr->end_handle() < seq_ptr->start_handle())
     return MB_FAILURE;
 
   iterator i = lower_bound( seq_ptr->start_handle() );
@@ -883,12 +884,13 @@
     // make sure lastReferenced points to something
   if (!lastReferenced)
     return false;
-  const EntitySequence* seq2 = find( lastReferenced->start_handle() );
-  if (seq2 != lastReferenced)
+ 
+  const_iterator seqi = sequenceSet.lower_bound( lastReferenced );
+  if (seqi == sequenceSet.end() || *seqi != lastReferenced )
     return false;
   
     // make sure passed sequence is in list
-  seq2 = find( seq->start_handle() );
+  const EntitySequence* seq2 = find( seq->start_handle() );
   if (seq2 != seq)
     return false;
   




More information about the moab-dev mailing list