Skip to content
Permalink
Browse files

Fix tessellator crash with 2d triangle again

Fixes #39976
  • Loading branch information
uclaros committed Nov 18, 2020
1 parent bcc8816 commit 6bc298456be1e5beae0eacbc6de3c8861adf04dd
Showing with 7 additions and 3 deletions.
  1. +5 −2 src/core/qgstessellator.cpp
  2. +2 −1 tests/src/3d/testqgstessellator.cpp
@@ -604,7 +604,7 @@ void QgsTessellator::addPolygon( const QgsPolygon &polygon, float extrusionHeigh
const double *zData = !mNoZ ? exterior->zData() : nullptr;
for ( int i = 0; i < 3; i++ )
{
float z = mNoZ ? 0 : *zData;
float z = !zData ? 0 : *zData;
if ( z < zMin )
zMin = z;
if ( z > zMax )
@@ -626,7 +626,10 @@ void QgsTessellator::addPolygon( const QgsPolygon &polygon, float extrusionHeigh
}
mData << p.first << p.second;
}
xData++; yData++; zData++;
xData++; yData++;
// zData can be nullptr if mNoZ or triangle is 2D
if ( zData )
zData++;
}

if ( mAddBackFaces )
@@ -406,7 +406,8 @@ void TestQgsTessellator::testCrash2DTriangle()
// test tessellation of a 2D triangle - https://github.com/qgis/QGIS/issues/36024
QgsPolygon polygon;
polygon.fromWkt( "Polygon((0 0, 42 0, 42 42, 0 0))" );
QgsTessellator t( 0, 0, true, false, false, true );
// must not be declared with mNoz = true
QgsTessellator t( 0, 0, true );
t.addPolygon( polygon, 0 ); // must not crash - that's all we test here
}

0 comments on commit 6bc2984

Please sign in to comment.
You can’t perform that action at this time.