Skip to content
Permalink
Browse files
[labeling] Ensure invalid rings are stripped from input geometries in…
… multipolygons before handing to pal

Fixes potential crash during labeling with complex coordinate transforms

Fixes #46727
  • Loading branch information
nyalldawson authored and github-actions committed Jan 11, 2022
1 parent ee345f3 commit 8f3f4467b7af9bd76ceae866b3c8ec9dafea39f8
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/core/labeling/qgspallabeling.cpp
@@ -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"
@@ -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

0 comments on commit 8f3f446

Please sign in to comment.