Navigation Menu

Skip to content

Commit

Permalink
Add a nullptr guard in the geometry equality check
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jan 20, 2019
1 parent 23885e5 commit b89e1f7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/core/geometry/qgsgeometrycollection.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit b89e1f7

Please sign in to comment.