Skip to content
Permalink
Browse files

Add a nullptr guard in the geometry equality check

  • Loading branch information
m-kuhn committed Jan 20, 2019
1 parent 23885e5 commit b89e1f74cc40c7b574fe4248ffc121f38eec5287
Showing with 13 additions and 3 deletions.
  1. +13 −3 src/core/geometry/qgsgeometrycollection.cpp
@@ -78,9 +78,19 @@ bool QgsGeometryCollection::operator==( const QgsAbstractGeometry &other ) const

for ( int i = 0; i < mGeometries.count(); ++i )
{
if ( mGeometries.at( i ) != otherCollection->mGeometries.at( i )
&& mGeometries.at( i )->operator!=( *otherCollection->mGeometries.at( i ) ) )
return false;
QgsAbstractGeometry *g1 = mGeometries.at( i );
QgsAbstractGeometry *g2 = otherCollection->mGeometries.at( i );

// Quick check if the geometries are exactly the same
if ( g1 != g2 )
{
if ( !g1 || !g2 )
return false;

// Slower check, compare the contents of the geometries
if ( *g1 != *g2 )
return false;
}
}

return true;

0 comments on commit b89e1f7

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