Jelajahi Sumber

Correction on clipper crash on some IFC files when points are empty

Arkeon 6 tahun lalu
induk
melakukan
b59d931486
1 mengubah file dengan 8 tambahan dan 2 penghapusan
  1. 8 2
      contrib/clipper/clipper.cpp

+ 8 - 2
contrib/clipper/clipper.cpp

@@ -371,6 +371,9 @@ inline bool PointsEqual( const IntPoint &pt1, const IntPoint &pt2)
 
 
 bool Orientation(OutRec *outRec, bool UseFullInt64Range)
 bool Orientation(OutRec *outRec, bool UseFullInt64Range)
 {
 {
+  if (!outRec->pts)
+    return 0.0;
+
   //first make sure bottomPt is correctly assigned ...
   //first make sure bottomPt is correctly assigned ...
   OutPt *opBottom = outRec->pts, *op = outRec->pts->next;
   OutPt *opBottom = outRec->pts, *op = outRec->pts->next;
   while (op != outRec->pts)
   while (op != outRec->pts)
@@ -434,6 +437,9 @@ double Area(const Polygon &poly)
 
 
 double Area(const OutRec &outRec, bool UseFullInt64Range)
 double Area(const OutRec &outRec, bool UseFullInt64Range)
 {
 {
+  if (!outRec.pts)
+    return 0.0;
+
   OutPt *op = outRec.pts;
   OutPt *op = outRec.pts;
   if (UseFullInt64Range) {
   if (UseFullInt64Range) {
     Int128 a(0);
     Int128 a(0);
@@ -3085,9 +3091,9 @@ void Clipper::JoinCommonEdges(bool fixHoleLinkages)
       FixupOutPolygon(*outRec1);
       FixupOutPolygon(*outRec1);
       FixupOutPolygon(*outRec2);
       FixupOutPolygon(*outRec2);
 
 
-      if (Orientation(outRec1, m_UseFullRange) != (Area(*outRec1, m_UseFullRange) > 0))
+      if (outRec1->pts && (Orientation(outRec1, m_UseFullRange) != (Area(*outRec1, m_UseFullRange) > 0)))
           DisposeBottomPt(*outRec1);
           DisposeBottomPt(*outRec1);
-      if (Orientation(outRec2, m_UseFullRange) != (Area(*outRec2, m_UseFullRange) > 0))
+      if (outRec2->pts && (Orientation(outRec2, m_UseFullRange) != (Area(*outRec2, m_UseFullRange) > 0)))
           DisposeBottomPt(*outRec2);
           DisposeBottomPt(*outRec2);
 
 
     } else
     } else