# IFC: fix potential crash during merging of polygon boundaries

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1016 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2011-05-30 21:04:11 +00:00
parent 23ea1ac97d
commit 15565c4858
2 changed files with 7 additions and 5 deletions

View File

@ -1047,17 +1047,20 @@ void MergePolygonBoundaries(TempMesh& result, const TempMesh& inmesh, size_t mas
// skip over extremely small boundaries - this is a workaround to fix cases // skip over extremely small boundaries - this is a workaround to fix cases
// in which the number of holes is so extremely large that the // in which the number of holes is so extremely large that the
// triangulation code fails. // triangulation code fails.
#define IFC_VERTICAL_HOLE_SIZE_TRESHOLD 0.000001f
size_t vidx = 0, removed = 0, index = 0; size_t vidx = 0, removed = 0, index = 0;
const float treshold = area_outer_polygon * 0.000001f; const float treshold = area_outer_polygon * IFC_VERTICAL_HOLE_SIZE_TRESHOLD;
for(iit = begin; iit != end ;++index) { for(iit = begin; iit != end ;++index) {
const float sqlen = normals[index].SquareLength(); const float sqlen = normals[index].SquareLength();
if (sqlen < treshold) { if (sqlen < treshold) {
std::vector<aiVector3D>::iterator inbase = in.begin()+vidx; std::vector<aiVector3D>::iterator inbase = in.begin()+vidx;
in.erase(inbase,inbase+*iit); in.erase(inbase,inbase+*iit);
*iit++ = 0;
outer_polygon_start -= outer_polygon_start>vidx ? *iit : 0; outer_polygon_start -= outer_polygon_start>vidx ? *iit : 0;
*iit++ = 0;
++removed; ++removed;
IFCImporter::LogDebug("skip small hole below treshold");
} }
else { else {
normals[index] /= sqrt(sqlen); normals[index] /= sqrt(sqlen);

View File

@ -445,11 +445,10 @@ STEP::LazyObject::~LazyObject()
{ {
// make sure the right dtor/operator delete get called // make sure the right dtor/operator delete get called
if (obj) { if (obj) {
delete obj;
delete conv_args; delete conv_args;
} }
else delete[] args; else delete[] args;
delete obj;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------