Merge pull request #28 from piotrkania-here/check_ptr

Check pointer before dereferencing it
This commit is contained in:
Jan Niklas Hasse 2021-04-26 17:02:23 +02:00 committed by GitHub
commit 4a323bf6d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,13 +65,15 @@ void Sweep::FinalizationPolygon(SweepContext& tcx)
// Get an Internal triangle to start with // Get an Internal triangle to start with
Triangle* t = tcx.front()->head()->next->triangle; Triangle* t = tcx.front()->head()->next->triangle;
Point* p = tcx.front()->head()->next->point; Point* p = tcx.front()->head()->next->point;
while (!t->GetConstrainedEdgeCW(*p)) { while (t && !t->GetConstrainedEdgeCW(*p)) {
t = t->NeighborCCW(*p); t = t->NeighborCCW(*p);
} }
// Collect interior triangles constrained by edges // Collect interior triangles constrained by edges
if (t) {
tcx.MeshClean(*t); tcx.MeshClean(*t);
} }
}
Node& Sweep::PointEvent(SweepContext& tcx, Point& point) Node& Sweep::PointEvent(SweepContext& tcx, Point& point)
{ {
@ -227,7 +229,7 @@ void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
// Fill right holes // Fill right holes
Node* node = n.next; Node* node = n.next;
while (node->next) { while (node && node->next) {
// if HoleAngle exceeds 90 degrees then break. // if HoleAngle exceeds 90 degrees then break.
if (LargeHole_DontFill(node)) break; if (LargeHole_DontFill(node)) break;
Fill(tcx, *node); Fill(tcx, *node);
@ -237,7 +239,7 @@ void Sweep::FillAdvancingFront(SweepContext& tcx, Node& n)
// Fill left holes // Fill left holes
node = n.prev; node = n.prev;
while (node->prev) { while (node && node->prev) {
// if HoleAngle exceeds 90 degrees then break. // if HoleAngle exceeds 90 degrees then break.
if (LargeHole_DontFill(node)) break; if (LargeHole_DontFill(node)) break;
Fill(tcx, *node); Fill(tcx, *node);