[cgma-dev] r3565 - cgm/trunk/itaps

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Thu Mar 4 08:45:36 CST 2010


Author: kraftche
Date: 2010-03-04 08:45:36 -0600 (Thu, 04 Mar 2010)
New Revision: 3565

Modified:
   cgm/trunk/itaps/iGeom_CGMA.cc
Log:
if getPntArrClsf returns failure, free the array if we allocated it

Modified: cgm/trunk/itaps/iGeom_CGMA.cc
===================================================================
--- cgm/trunk/itaps/iGeom_CGMA.cc	2010-03-04 14:41:11 UTC (rev 3564)
+++ cgm/trunk/itaps/iGeom_CGMA.cc	2010-03-04 14:45:36 UTC (rev 3565)
@@ -3191,22 +3191,27 @@
   const double *y = x + init;
   const double *z = y + init;
   
+  const bool allocated = !!*entity_handles;
   CHECK_SIZE( *entity_handles, iBase_EntityHandle, count );
   
-  iBase_ErrorType result = iBase_SUCCESS;
   RefEntity** array = (RefEntity**)*entity_handles;
   for (int i = 0; i < count; ++i)
   {
     const CubitVector pt( *x, *y, *z );
     array[i] = iGeom_get_point_containment( pt );
-    if (!array[i])
-      result = iBase_FAILURE;
+    if (!array[i]) {
+      if (allocated) {
+        free(*entity_handles);
+        *entity_handles_allocated = 0;
+      }
+      RETURN(iBase_FAILURE);
+    }
     x += step;
     y += step;
     z += step;
   }
   
-  RETURN(result);
+  RETURN(iBase_SUCCESS);
 }
 
 /**



More information about the cgma-dev mailing list