Skip to content

Commit

Permalink
[labeling] Ensure invalid rings are stripped from input geometries in…
Browse files Browse the repository at this point in the history
… multipolygons before handing to pal

Fixes potential crash during labeling with complex coordinate transforms

Fixes #46727
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Jan 11, 2022
1 parent ee345f3 commit 8f3f446
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/core/labeling/qgspallabeling.cpp
Expand Up @@ -56,7 +56,7 @@
#include "qgsvectorlayerlabeling.h"
#include "qgstextrendererutils.h"
#include "qgstextfragment.h"

#include "qgsmultisurface.h"
#include "qgslogger.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
Expand Down Expand Up @@ -3807,7 +3807,17 @@ QgsGeometry QgsPalLabeling::prepareGeometry( const QgsGeometry &geometry, QgsRen
return std::isfinite( point.x() ) && std::isfinite( point.y() );
} );
if ( QgsCurvePolygon *cp = qgsgeometry_cast< QgsCurvePolygon * >( geom.get() ) )
{
cp->removeInvalidRings();
}
else if ( QgsMultiSurface *ms = qgsgeometry_cast< QgsMultiSurface * >( geom.get() ) )
{
for ( int i = 0; i < ms->numGeometries(); ++i )
{
if ( QgsCurvePolygon *cp = qgsgeometry_cast< QgsCurvePolygon * >( ms->geometryN( i ) ) )
cp->removeInvalidRings();
}
}
}

// Rotate the geometry if needed, before clipping
Expand Down

0 comments on commit 8f3f446

Please sign in to comment.